Menu Close

Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

6.3. 由​​​​​​​ LVM 鏡​​​​​​​像​​​​​​​錯​​​​​​​誤​​​​​​​中​​​​​​​復​​​​​​​原​​​​​​​

此​​​​​​​部​​​​​​​份​​​​​​​提​​​​​​​供​​​​​​​了​​​​​​​一​​​​​​​個​​​​​​​從​​​​​​​「​​​​​​​基​​​​​​​於​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​基​​​​​​​本​​​​​​​裝​​​​​​​置​​​​​​​發​​​​​​​生​​​​​​​了​​​​​​​錯​​​​​​​誤​​​​​​​所​​​​​​​造​​​​​​​成​​​​​​​的​​​​​​​ LVM 鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​ leg 錯​​​​​​​誤​​​​​​​」​​​​​​​的​​​​​​​情​​​​​​​況​​​​​​​下​​​​​​​復​​​​​​​原​​​​​​​之​​​​​​​範​​​​​​​例​​​​​​​。​​​​​​​當​​​​​​​一​​​​​​​個​​​​​​​鏡​​​​​​​像​​​​​​​ leg 發​​​​​​​生​​​​​​​錯​​​​​​​誤​​​​​​​時​​​​​​​,LVM 便​​​​​​​會​​​​​​​將​​​​​​​鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​轉​​​​​​​換​​​​​​​為​​​​​​​線​​​​​​​性​​​​​​​卷​​​​​​​冊​​​​​​​,它​​​​​​​會​​​​​​​和​​​​​​​先​​​​​​​前​​​​​​​相​​​​​​​同​​​​​​​地​​​​​​​繼​​​​​​​續​​​​​​​進​​​​​​​行​​​​​​​作​​​​​​​業​​​​​​​不​​​​​​​過​​​​​​​缺​​​​​​​少​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​重​​​​​​​複​​​​​​​。​​​​​​​在​​​​​​​此​​​​​​​情​​​​​​​況​​​​​​​下​​​​​​​,您​​​​​​​可​​​​​​​新​​​​​​​增​​​​​​​一​​​​​​​個​​​​​​​新​​​​​​​的​​​​​​​磁​​​​​​​碟​​​​​​​裝​​​​​​​置​​​​​​​至​​​​​​​系​​​​​​​統​​​​​​​,使​​​​​​​用​​​​​​​它​​​​​​​來​​​​​​​取​​​​​​​代​​​​​​​實​​​​​​​體​​​​​​​裝​​​​​​​置​​​​​​​並​​​​​​​重​​​​​​​建​​​​​​​鏡​​​​​​​像​​​​​​​。​​​​​​​
下​​​​​​​列​​​​​​​指​​​​​​​令​​​​​​​建​​​​​​​立​​​​​​​了​​​​​​​將​​​​​​​會​​​​​​​使​​​​​​​用​​​​​​​於​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​
[root@link-08 ~]# pvcreate /dev/sd[abcdefgh][12]
  Physical volume "/dev/sda1" successfully created
  Physical volume "/dev/sda2" successfully created
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdb2" successfully created
  Physical volume "/dev/sdc1" successfully created
  Physical volume "/dev/sdc2" successfully created
  Physical volume "/dev/sdd1" successfully created
  Physical volume "/dev/sdd2" successfully created
  Physical volume "/dev/sde1" successfully created
  Physical volume "/dev/sde2" successfully created
  Physical volume "/dev/sdf1" successfully created
  Physical volume "/dev/sdf2" successfully created
  Physical volume "/dev/sdg1" successfully created
  Physical volume "/dev/sdg2" successfully created
  Physical volume "/dev/sdh1" successfully created
  Physical volume "/dev/sdh2" successfully created
下​​​​​​​列​​​​​​​指​​​​​​​令​​​​​​​建​​​​​​​立​​​​​​​了​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​ vg 和​​​​​​​鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​ groupfs。​​​​​​​
[root@link-08 ~]# vgcreate vg /dev/sd[abcdefgh][12]
  Volume group "vg" successfully created
[root@link-08 ~]# lvcreate -L 750M -n groupfs -m 1 vg /dev/sda1 /dev/sdb1 /dev/sdc1
  Rounding up size to full physical extent 752.00 MB
  Logical volume "groupfs" created
您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ lvs 指​​​​​​​令​​​​​​​來​​​​​​​驗​​​​​​​證​​​​​​​ mirror leg 和​​​​​​​ mirror log 的​​​​​​​基​​​​​​​本​​​​​​​裝​​​​​​​置​​​​​​​和​​​​​​​鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​格​​​​​​​式​​​​​​​。​​​​​​​請​​​​​​​注​​​​​​​意​​​​​​​,在​​​​​​​第​​​​​​​一​​​​​​​個​​​​​​​範​​​​​​​例​​​​​​​中​​​​​​​,鏡​​​​​​​像​​​​​​​還​​​​​​​未​​​​​​​完​​​​​​​整​​​​​​​同​​​​​​​步​​​​​​​化​​​​​​​;您​​​​​​​應​​​​​​​等​​​​​​​到​​​​​​​ Copy% 這​​​​​​​個​​​​​​​欄​​​​​​​位​​​​​​​顯​​​​​​​示​​​​​​​了​​​​​​​ 100.00 之​​​​​​​後​​​​​​​才​​​​​​​繼​​​​​​​續​​​​​​​進​​​​​​​行​​​​​​​。​​​​​​​
[root@link-08 ~]# lvs -a -o +devices
  LV                 VG   Attr   LSize   Origin Snap%  Move Log          Copy% Devices
  groupfs            vg   mwi-a- 752.00M                    groupfs_mlog 21.28 groupfs_mimage_0(0),groupfs_mimage_1(0)
  [groupfs_mimage_0] vg   iwi-ao 752.00M                                       /dev/sda1(0)
  [groupfs_mimage_1] vg   iwi-ao 752.00M                                       /dev/sdb1(0)
  [groupfs_mlog]     vg   lwi-ao   4.00M                                       /dev/sdc1(0)

[root@link-08 ~]# lvs -a -o +devices
  LV                 VG   Attr   LSize   Origin Snap%  Move Log          Copy%  Devices
  groupfs            vg   mwi-a- 752.00M                    groupfs_mlog 100.00 groupfs_mimage_0(0),groupfs_mimage_1(0)
  [groupfs_mimage_0] vg   iwi-ao 752.00M                                        /dev/sda1(0)
  [groupfs_mimage_1] vg   iwi-ao 752.00M                                        /dev/sdb1(0)
  [groupfs_mlog]     vg   lwi-ao   4.00M     i                                  /dev/sdc1(0)
在​​​​​​​此​​​​​​​範​​​​​​​例​​​​​​​中​​​​​​​,/dev/sda1 這​​​​​​​個​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​主​​​​​​​要​​​​​​​ leg 發​​​​​​​生​​​​​​​了​​​​​​​錯​​​​​​​誤​​​​​​​。​​​​​​​任​​​​​​​何​​​​​​​寫​​​​​​​入​​​​​​​至​​​​​​​鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​動​​​​​​​作​​​​​​​都​​​​​​​會​​​​​​​造​​​​​​​成​​​​​​​ LVM 偵​​​​​​​測​​​​​​​到​​​​​​​錯​​​​​​​誤​​​​​​​的​​​​​​​鏡​​​​​​​像​​​​​​​。​​​​​​​當​​​​​​​這​​​​​​​情​​​​​​​況​​​​​​​發​​​​​​​生​​​​​​​時​​​​​​​,LVM 會​​​​​​​將​​​​​​​鏡​​​​​​​像​​​​​​​轉​​​​​​​換​​​​​​​為​​​​​​​單​​​​​​​獨​​​​​​​的​​​​​​​線​​​​​​​性​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​在​​​​​​​此​​​​​​​情​​​​​​​況​​​​​​​下​​​​​​​,若​​​​​​​要​​​​​​​進​​​​​​​行​​​​​​​轉​​​​​​​換​​​​​​​的​​​​​​​話​​​​​​​,請​​​​​​​執​​​​​​​行​​​​​​​ dd 這​​​​​​​項​​​​​​​指​​​​​​​令​​​​​​​
[root@link-08 ~]# dd if=/dev/zero of=/dev/vg/groupfs count=10
10+0 records in
10+0 records out
您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ lvs 指​​​​​​​令​​​​​​​來​​​​​​​驗​​​​​​​證​​​​​​​裝​​​​​​​置​​​​​​​現​​​​​​​在​​​​​​​是​​​​​​​否​​​​​​​是​​​​​​​個​​​​​​​ linear 裝​​​​​​​置​​​​​​​。​​​​​​​因​​​​​​​為​​​​​​​磁​​​​​​​碟​​​​​​​發​​​​​​​生​​​​​​​錯​​​​​​​誤​​​​​​​,因​​​​​​​而​​​​​​​產​​​​​​​生​​​​​​​了​​​​​​​ I/O 錯​​​​​​​誤​​​​​​​。​​​​​​​
[root@link-08 ~]# lvs -a -o +devices
  /dev/sda1: read failed after 0 of 2048 at 0: Input/output error
  /dev/sda2: read failed after 0 of 2048 at 0: Input/output error
  LV      VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices
  groupfs vg   -wi-a- 752.00M                               /dev/sdb1(0)
在​​​​​​​此​​​​​​​情​​​​​​​況​​​​​​​下​​​​​​​,您​​​​​​​還​​​​​​​是​​​​​​​應​​​​​​​該​​​​​​​能​​​​​​​使​​​​​​​用​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​,不​​​​​​​過​​​​​​​將​​​​​​​不​​​​​​​會​​​​​​​有​​​​​​​鏡​​​​​​​像​​​​​​​重​​​​​​​複​​​​​​​。​​​​​​​
To rebuild the mirrored volume, you replace the broken drive and recreate the physical volume. If you use the same disk rather than replacing it with a new one, you will see "inconsistent" warnings when you run the pvcreate command.
[root@link-08 ~]# pvcreate /dev/sda[12]
  Physical volume "/dev/sda1" successfully created
  Physical volume "/dev/sda2" successfully created

[root@link-08 ~]# pvscan
  PV /dev/sdb1   VG vg   lvm2 [67.83 GB / 67.10 GB free]
  PV /dev/sdb2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdc1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdc2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdd1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdd2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sde1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sde2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdf1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdf2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdg1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdg2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdh1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdh2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sda1           lvm2 [603.94 GB]
  PV /dev/sda2           lvm2 [603.94 GB]
  Total: 16 [2.11 TB] / in use: 14 [949.65 GB] / in no VG: 2 [1.18 TB]
接​​​​​​​下​​​​​​​來​​​​​​​請​​​​​​​透​​​​​​​過​​​​​​​新​​​​​​​的​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​來​​​​​​​延​​​​​​​伸​​​​​​​原​​​​​​​始​​​​​​​的​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​。​​​​​​​
[root@link-08 ~]# vgextend vg /dev/sda[12]
  Volume group "vg" successfully extended

[root@link-08 ~]# pvscan
  PV /dev/sdb1   VG vg   lvm2 [67.83 GB / 67.10 GB free]
  PV /dev/sdb2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdc1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdc2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdd1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdd2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sde1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sde2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdf1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdf2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdg1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdg2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdh1   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sdh2   VG vg   lvm2 [67.83 GB / 67.83 GB free]
  PV /dev/sda1   VG vg   lvm2 [603.93 GB / 603.93 GB free]
  PV /dev/sda2   VG vg   lvm2 [603.93 GB / 603.93 GB free]
  Total: 16 [2.11 TB] / in use: 16 [2.11 TB] / in no VG: 0 [0   ]
將​​​​​​​ linear 卷​​​​​​​冊​​​​​​​轉​​​​​​​換​​​​​​​回​​​​​​​它​​​​​​​原​​​​​​​始​​​​​​​的​​​​​​​鏡​​​​​​​像​​​​​​​狀​​​​​​​態​​​​​​​。​​​​​​​
[root@link-08 ~]# lvconvert -m 1 /dev/vg/groupfs /dev/sda1 /dev/sdb1 /dev/sdc1
  Logical volume mirror converted.
您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ lvs 指​​​​​​​令​​​​​​​來​​​​​​​驗​​​​​​​證​​​​​​​鏡​​​​​​​像​​​​​​​是​​​​​​​否​​​​​​​已​​​​​​​被​​​​​​​儲​​​​​​​存​​​​​​​。​​​​​​​
[root@link-08 ~]# lvs -a -o +devices
  LV                 VG   Attr   LSize   Origin Snap%  Move Log          Copy% Devices
  groupfs            vg   mwi-a- 752.00M                    groupfs_mlog 68.62 groupfs_mimage_0(0),groupfs_mimage_1(0)
  [groupfs_mimage_0] vg   iwi-ao 752.00M                                       /dev/sdb1(0)
  [groupfs_mimage_1] vg   iwi-ao 752.00M                                       /dev/sda1(0)
  [groupfs_mlog]     vg   lwi-ao   4.00M                                       /dev/sdc1(0)