搜索

6.3. 修​​​​​​​复​​​​​​​ LVM 镜​​​​​​​像​​​​​​​错​​​​​​​误​​​​​​​

download PDF
这​​​​​​​部​​​​​​​分​​​​​​​提​​​​​​​供​​​​​​​了​​​​​​​一​​​​​​​个​​​​​​​修​​​​​​​复​​​​​​​示​​​​​​​例​​​​​​​,即​​​​​​​ LVM 镜​​​​​​​像​​​​​​​的​​​​​​​一​​​​​​​个​​​​​​​分​​​​​​​支​​​​​​​失​​​​​​​败​​​​​​​,是​​​​​​​因​​​​​​​为​​​​​​​物​​​​​​​理​​​​​​​卷​​​​​​​的​​​​​​​基​​​​​​​本​​​​​​​设​​​​​​​备​​​​​​​死​​​​​​​机​​​​​​​。​​​​​​​当​​​​​​​一​​​​​​​个​​​​​​​镜​​​​​​​像​​​​​​​分​​​​​​​支​​​​​​​失​​​​​​​败​​​​​​​时​​​​​​​,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 命​​​​​​​令​​​​​​​确​​​​​​​定​​​​​​​镜​​​​​​​像​​​​​​​卷​​​​​​​、​​​​​​​用​​​​​​​于​​​​​​​镜​​​​​​​像​​​​​​​分​​​​​​​支​​​​​​​的​​​​​​​基​​​​​​​本​​​​​​​设​​​​​​​备​​​​​​​以​​​​​​​及​​​​​​​镜​​​​​​​像​​​​​​​分​​​​​​​支​​​​​​​的​​​​​​​布​​​​​​​局​​​​​​​。​​​​​​​请​​​​​​​注​​​​​​​意​​​​​​​:在​​​​​​​第​​​​​​​一​​​​​​​个​​​​​​​示​​​​​​​例​​​​​​​中​​​​​​​,镜​​​​​​​像​​​​​​​还​​​​​​​没​​​​​​​有​​​​​​​被​​​​​​​完​​​​​​​全​​​​​​​同​​​​​​​步​​​​​​​,您​​​​​​​应​​​​​​​该​​​​​​​在​​​​​​​ 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 的​​​​​​​主​​​​​​​要​​​​​​​分​​​​​​​支​​​​​​​失​​​​​​​败​​​​​​​。​​​​​​​任​​​​​​​何​​​​​​​对​​​​​​​镜​​​​​​​像​​​​​​​卷​​​​​​​的​​​​​​​写​​​​​​​入​​​​​​​操​​​​​​​作​​​​​​​都​​​​​​​会​​​​​​​导​​​​​​​致​​​​​​​ 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 命​​​​​​​令​​​​​​​确​​​​​​​定​​​​​​​该​​​​​​​设​​​​​​​备​​​​​​​现​​​​​​​在​​​​​​​已​​​​​​​经​​​​​​​是​​​​​​​线​​​​​​​性​​​​​​​设​​​​​​​备​​​​​​​了​​​​​​​。​​​​​​​因​​​​​​​为​​​​​​​是​​​​​​​失​​​​​​​败​​​​​​​的​​​​​​​磁​​​​​​​盘​​​​​​​,所​​​​​​​以​​​​​​​会​​​​​​​发​​​​​​​生​​​​​​​ 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   ]
将​​​​​​​线​​​​​​​性​​​​​​​卷​​​​​​​转​​​​​​​换​​​​​​​回​​​​​​​它​​​​​​​原​​​​​​​来​​​​​​​的​​​​​​​镜​​​​​​​像​​​​​​​状​​​​​​​态​​​​​​​。​​​​​​​
[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)
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.