Chinaunix首页 | 论坛 | 博客
  • 博客访问: 488501
  • 博文数量: 82
  • 博客积分: 3003
  • 博客等级: 中校
  • 技术积分: 1285
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-11 15:27
文章分类

全部博文(82)

文章存档

2011年(1)

2010年(5)

2009年(63)

2008年(13)

我的朋友

分类: LINUX

2009-08-17 21:15:22

Recovering PV of Mirrored LVM

Author:Jaylin Zhou

Now there are three PVs:

# pvs
  PV VG Fmt Attr PSize PFree
  /dev/sdb5 lvm2 -- 196.08M 196.08M
  /dev/sdb6 lvm2 -- 196.08M 196.08M
  /dev/sdb7 lvm2 -- 196.08M 196.08M

Create a VG with this three PVs:

# vgcreate /dev/myvg /dev/sdb[567]
  Volume group "myvg" successfully created

Check the status of VG:

# vgs
  VG #PV #LV #SN Attr VSize VFree
  myvg 3 0 0 wz--n- 576.00M 576.00M

Create a one-mirrored LV by putting the two mirror legs in /dev/sdb5 and /dev/sdb6, putting log in /dev/sdb7 :

# lvcreate -l 20 -n mylv -m1 /dev/myvg /dev/sdb5 /dev/sdb6 /dev/sdb7
  Logical volume "mylv" created

Check the status of LV and find the mirrored LV is available:

# lvs -a -o +devices
  LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
  mylv myvg mwi-a- 80.00M mylv_mlog 100.00 mylv_mimage_0(0),mylv_mimage_1(0)
  [mylv_mimage_0] myvg iwi-ao 80.00M /dev/sdb5(0)
  [mylv_mimage_1] myvg iwi-ao 80.00M /dev/sdb6(0)
  [mylv_mlog] myvg lwi-ao 4.00M /dev/sdb7(0)

Make a file system on LV:

# mkfs.ext3 /dev/myvg/mylv

Mount LV then add some data on it:

# mount /dev/myvg/mylv /mnt/
# umount /mnt/

Destroy one mirror leg, in the example i.e. /dev/sdb5 :

# dd if=/dev/zero of=/dev/sdb5 count=10

Check the status of LV and find a device is unavailable:

# lvs
  Couldn't find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH'.
  Couldn'
t find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH'.
  LV VG Attr LSize Origin Snap% Move Log Copy% Convert
  mylv myvg mwi-a- 80.00M mylv_mlog 100.00

Mount LV and it is still available:

# mount /dev/myvg/mylv /mnt/

Check the status of PVS and find an unknown device:

# pvs
  Couldn't find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH

Make VG unavailable:

# vgchange -an /dev/myvg
  Couldn't find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH'.
  Couldn'
t find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH'.
  Couldn't find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH'.
  /dev/mapper/myvg-mylv_mlog: stat failed: No such file or directory
  Path /dev/mapper/myvg-mylv_mlog no longer valid for device(253,0)
  /dev/mapper/myvg-mylv_mimage_0: stat failed: No such file or directory
  Path /dev/mapper/myvg-mylv_mimage_0 no longer valid for device(253,1)
  /dev/mapper/myvg-mylv_mimage_1: stat failed: No such file or directory
  Path /dev/mapper/myvg-mylv_mimage_1 no longer valid for device(253,2)
  /dev/myvg/mylv: stat failed: No such file or directory
  Path /dev/myvg/mylv no longer valid for device(253,3)
  /dev/mapper/myvg-mylv: stat failed: No such file or directory
  Path /dev/mapper/myvg-mylv no longer valid for device(253,3)
  Couldn'
t find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH'.
  0 logical volume(s) in volume group "myvg" now active

Recover the destroyed PV: 

# pvcreate --uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH' --restorefile /etc/lvm/archive/myvg_00070.vg /dev/sdb5
  Couldn't find device with uuid 'XTXw2z-p4LH-MBGd-AeG2-JNGx-r3nz-xz2lEH

Restore the VG's metadata:

# vgcfgrestore /dev/myvg
  Restored volume group myvg

Check the status of LV and find the destroyed mirror is normal, but the LV is unavailable:

# lvs -a -o +devices
  LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
  mylv myvg mwi--- 80.00M mylv_mlog mylv_mimage_0(0),mylv_mimage_1(0)
  [mylv_mimage_0] myvg Iwi--- 80.00M /dev/sdb5(0)
  [mylv_mimage_1] myvg Iwi--- 80.00M /dev/sdb6(0)
  [mylv_mlog] myvg lwi--- 4.00M /dev/sdb7(0)

Make the LV available:

# lvchange -ay /dev/myvg/mylv

Check the status of LV again and find the LV is available:

# lvs -a -o +devices
  LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
  mylv myvg mwi-a- 80.00M mylv_mlog 100.00 mylv_mimage_0(0),mylv_mimage_1(0)
  [mylv_mimage_0] myvg iwi-ao 80.00M /dev/sdb5(0)
  [mylv_mimage_1] myvg iwi-ao 80.00M /dev/sdb6(0)
  [mylv_mlog] myvg lwi-ao 4.00M /dev/sdb7(0)

Mount LV and find it is available:

# mount /dev/myvg/mylv /mnt/
# umount /mnt

阅读(1662) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~