Menu Close

Red Hat Training

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

6.4. 復​​​​​​​原​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​ Metadata

若​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​ metadata 區​​​​​​​域​​​​​​​不​​​​​​​小​​​​​​​心​​​​​​​被​​​​​​​覆​​​​​​​寫​​​​​​​或​​​​​​​損​​​​​​​毀​​​​​​​的​​​​​​​話​​​​​​​,您​​​​​​​將​​​​​​​會​​​​​​​看​​​​​​​見​​​​​​​一​​​​​​​則​​​​​​​顯​​​​​​​示​​​​​​​ metadata 區​​​​​​​域​​​​​​​不​​​​​​​正​​​​​​​確​​​​​​​,或​​​​​​​是​​​​​​​系​​​​​​​統​​​​​​​無​​​​​​​法​​​​​​​找​​​​​​​到​​​​​​​含​​​​​​​有​​​​​​​某​​​​​​​個​​​​​​​ UUID 的​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​錯​​​​​​​誤​​​​​​​訊​​​​​​​息​​​​​​​。​​​​​​​您​​​​​​​可​​​​​​​藉​​​​​​​由​​​​​​​在​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​上​​​​​​​編​​​​​​​寫​​​​​​​新​​​​​​​的​​​​​​​ metadata 區​​​​​​​域​​​​​​​,指​​​​​​​定​​​​​​​和​​​​​​​遺​​​​​​​失​​​​​​​的​​​​​​​ metadata 相​​​​​​​同​​​​​​​的​​​​​​​ UUID 來​​​​​​​恢​​​​​​​復​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​資​​​​​​​料​​​​​​​。​​​​​​​

警告

您​​​​​​​不​​​​​​​該​​​​​​​以​​​​​​​一​​​​​​​個​​​​​​​可​​​​​​​運​​​​​​​作​​​​​​​的​​​​​​​ LVM 邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​來​​​​​​​嘗​​​​​​​試​​​​​​​這​​​​​​​項​​​​​​​程​​​​​​​序​​​​​​​。​​​​​​​若​​​​​​​您​​​​​​​指​​​​​​​定​​​​​​​了​​​​​​​錯​​​​​​​誤​​​​​​​的​​​​​​​ UUID,您​​​​​​​將​​​​​​​會​​​​​​​遺​​​​​​​失​​​​​​​您​​​​​​​的​​​​​​​資​​​​​​​料​​​​​​​。​​​​​​​
下​​​​​​​列​​​​​​​範​​​​​​​例​​​​​​​顯​​​​​​​示​​​​​​​了​​​​​​​當​​​​​​​ metadata 遺​​​​​​​失​​​​​​​或​​​​​​​損​​​​​​​毀​​​​​​​時​​​​​​​您​​​​​​​所​​​​​​​可​​​​​​​能​​​​​​​會​​​​​​​看​​​​​​​見​​​​​​​的​​​​​​​輸​​​​​​​出​​​​​​​。​​​​​​​
[root@link-07 backup]# lvs -a -o +devices
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  Couldn't find all physical volumes for volume group VG.
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  Couldn't find all physical volumes for volume group VG.
  ...
您​​​​​​​可​​​​​​​能​​​​​​​能​​​​​​​夠​​​​​​​透​​​​​​​過​​​​​​​查​​​​​​​看​​​​​​​ /etc/lvm/archive 目​​​​​​​錄​​​​​​​來​​​​​​​找​​​​​​​尋​​​​​​​被​​​​​​​覆​​​​​​​寫​​​​​​​的​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​ UUID。​​​​​​​若​​​​​​​要​​​​​​​找​​​​​​​尋​​​​​​​特​​​​​​​定​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​最​​​​​​​後​​​​​​​一​​​​​​​個​​​​​​​已​​​​​​​知​​​​​​​、​​​​​​​有​​​​​​​效​​​​​​​、​​​​​​​壓​​​​​​​縮​​​​​​​過​​​​​​​的​​​​​​​ LVM metadata,請​​​​​​​查​​​​​​​看​​​​​​​ VolumeGroupName_xxxx.vg 檔​​​​​​​案​​​​​​​。​​​​​​​
此​​​​​​​外​​​​​​​,您​​​​​​​可​​​​​​​能​​​​​​​會​​​​​​​發​​​​​​​現​​​​​​​停​​​​​​​用​​​​​​​卷​​​​​​​冊​​​​​​​並​​​​​​​設​​​​​​​置​​​​​​​ partial-P)引​​​​​​​數​​​​​​​能​​​​​​​讓​​​​​​​您​​​​​​​找​​​​​​​到​​​​​​​遺​​​​​​​失​​​​​​​或​​​​​​​損​​​​​​​毀​​​​​​​的​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​ UUID。​​​​​​​
[root@link-07 backup]# vgchange -an --partial
  Partial mode. Incomplete volume groups will be activated read-only.
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  ...
您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ pvcreate 指​​​​​​​令​​​​​​​的​​​​​​​ --uuid 和​​​​​​​ --restorefile 引​​​​​​​數​​​​​​​來​​​​​​​復​​​​​​​原​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​下​​​​​​​列​​​​​​​範​​​​​​​例​​​​​​​已​​​​​​​將​​​​​​​ /dev/sdh1 裝​​​​​​​置​​​​​​​標​​​​​​​記​​​​​​​為​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​和​​​​​​​以​​​​​​​上​​​​​​​所​​​​​​​顯​​​​​​​示​​​​​​​的​​​​​​​ UUID(FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk)。​​​​​​​這​​​​​​​項​​​​​​​指​​​​​​​令​​​​​​​會​​​​​​​透​​​​​​​過​​​​​​​包​​​​​​​含​​​​​​​在​​​​​​​ VG_00050.vg 中​​​​​​​的​​​​​​​ metadata 資​​​​​​​訊​​​​​​​(卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​ 最​​​​​​​近​​​​​​​期​​​​​​​的​​​​​​​良​​​​​​​好​​​​​​​壓​​​​​​​縮​​​​​​​的​​​​​​​ metadata)來​​​​​​​將​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​標​​​​​​​籤​​​​​​​恢​​​​​​​復​​​​​​​。​​​​​​​restorefile 引​​​​​​​數​​​​​​​會​​​​​​​指​​​​​​​示​​​​​​​ pvcreate 指​​​​​​​令​​​​​​​去​​​​​​​使​​​​​​​新​​​​​​​的​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​能​​​​​​​和​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​上​​​​​​​的​​​​​​​舊​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​相​​​​​​​容​​​​​​​,並​​​​​​​確​​​​​​​保​​​​​​​新​​​​​​​的​​​​​​​ metadata 不​​​​​​​會​​​​​​​被​​​​​​​放​​​​​​​置​​​​​​​在​​​​​​​舊​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​包​​​​​​​含​​​​​​​著​​​​​​​資​​​​​​​料​​​​​​​的​​​​​​​位​​​​​​​置​​​​​​​上​​​​​​​(這​​​​​​​是​​​​​​​有​​​​​​​可​​​​​​​能​​​​​​​會​​​​​​​發​​​​​​​生​​​​​​​的​​​​​​​,比​​​​​​​方​​​​​​​說​​​​​​​在​​​​​​​原​​​​​​​始​​​​​​​的​​​​​​​ pvcreate 指​​​​​​​令​​​​​​​有​​​​​​​使​​​​​​​用​​​​​​​控​​​​​​​制​​​​​​​ metadata 定​​​​​​​位​​​​​​​的​​​​​​​指​​​​​​​令​​​​​​​列​​​​​​​引​​​​​​​數​​​​​​​的​​​​​​​情​​​​​​​況​​​​​​​下​​​​​​​,或​​​​​​​是​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​原​​​​​​​本​​​​​​​是​​​​​​​透​​​​​​​過​​​​​​​使​​​​​​​用​​​​​​​不​​​​​​​同​​​​​​​預​​​​​​​設​​​​​​​值​​​​​​​的​​​​​​​不​​​​​​​同​​​​​​​版​​​​​​​本​​​​​​​軟​​​​​​​體​​​​​​​來​​​​​​​建​​​​​​​立​​​​​​​的​​​​​​​情​​​​​​​況​​​​​​​下​​​​​​​)。​​​​​​​pvcreate 指​​​​​​​令​​​​​​​只​​​​​​​會​​​​​​​將​​​​​​​ LVM metadata 區​​​​​​​域​​​​​​​覆​​​​​​​寫​​​​​​​而​​​​​​​不​​​​​​​會​​​​​​​影​​​​​​​響​​​​​​​到​​​​​​​現​​​​​​​有​​​​​​​的​​​​​​​資​​​​​​​料​​​​​​​區​​​​​​​域​​​​​​​。​​​​​​​
[root@link-07 backup]# pvcreate --uuid "FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk" --restorefile /etc/lvm/archive/VG_00050.vg /dev/sdh1
  Physical volume "/dev/sdh1" successfully created
You can then use the vgcfgrestore command to restore the volume group's metadata.
[root@link-07 backup]# vgcfgrestore VG
  Restored volume group VG
您​​​​​​​現​​​​​​​在​​​​​​​能​​​​​​​夠​​​​​​​顯​​​​​​​示​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​了​​​​​​​。​​​​​​​
[root@link-07 backup]# lvs -a -o +devices
  LV     VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices
  stripe VG   -wi--- 300.00G                               /dev/sdh1 (0),/dev/sda1(0)
  stripe VG   -wi--- 300.00G                               /dev/sdh1 (34728),/dev/sdb1(0)
下​​​​​​​列​​​​​​​指​​​​​​​令​​​​​​​會​​​​​​​啟​​​​​​​用​​​​​​​卷​​​​​​​冊​​​​​​​並​​​​​​​顯​​​​​​​示​​​​​​​啟​​​​​​​用​​​​​​​的​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​
[root@link-07 backup]# lvchange -ay /dev/VG/stripe
[root@link-07 backup]# lvs -a -o +devices
  LV     VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices
  stripe VG   -wi-a- 300.00G                               /dev/sdh1 (0),/dev/sda1(0)
  stripe VG   -wi-a- 300.00G                               /dev/sdh1 (34728),/dev/sdb1(0)
若​​​​​​​ on-disk 的​​​​​​​ LVM metadata 所​​​​​​​需​​​​​​​容​​​​​​​量​​​​​​​和​​​​​​​將​​​​​​​它​​​​​​​覆​​​​​​​寫​​​​​​​的​​​​​​​資​​​​​​​料​​​​​​​相​​​​​​​同​​​​​​​,這​​​​​​​項​​​​​​​指​​​​​​​令​​​​​​​便​​​​​​​可​​​​​​​將​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​復​​​​​​​原​​​​​​​。​​​​​​​若​​​​​​​將​​​​​​​ metadata 覆​​​​​​​寫​​​​​​​的​​​​​​​資​​​​​​​料​​​​​​​超​​​​​​​過​​​​​​​了​​​​​​​ metadata 範​​​​​​​圍​​​​​​​,那​​​​​​​麼​​​​​​​卷​​​​​​​冊​​​​​​​上​​​​​​​的​​​​​​​資​​​​​​​料​​​​​​​就​​​​​​​可​​​​​​​能​​​​​​​會​​​​​​​被​​​​​​​影​​​​​​​響​​​​​​​到​​​​​​​。​​​​​​​您​​​​​​​可​​​​​​​能​​​​​​​能​​​​​​​夠​​​​​​​透​​​​​​​過​​​​​​​使​​​​​​​用​​​​​​​ fsck 指​​​​​​​令​​​​​​​來​​​​​​​將​​​​​​​資​​​​​​​料​​​​​​​復​​​​​​​原​​​​​​​。​​​​​​​