一 、不要unknown的那块pv盘的解决办法
[root@gezi ~]# pvs WARNING: Device for PV D1LLfT-3Hle-NbrP-5165-Q6WR-2UWF-2xEIR3 not found or rejected by a filter. PV VG Fmt Attr PSize PFree /dev/xvda2 vg1 lvm2 a-- 79.51g 23.62g /dev/xvdb lvm2 --- 250.00g 250.00g unknown device vg1 lvm2 a-m 250.00g 250.00g [root@gezi ~]# vgs WARNING: Device for PV D1LLfT-3Hle-NbrP-5165-Q6WR-2UWF-2xEIR3 not found or rejected by a filter. VG #PV #LV #SN Attr VSize VFree vg1 2 2 0 wz-pn- 329.50g 273.62g [root@gezi ~]# vgreduce --removemissing /dev/vg1 WARNING: Device for PV D1LLfT-3Hle-NbrP-5165-Q6WR-2UWF-2xEIR3 not found or rejected by a filter. WARNING: Device for PV D1LLfT-3Hle-NbrP-5165-Q6WR-2UWF-2xEIR3 not found or rejected by a filter. Wrote out consistent volume group vg1 [root@gezi ~]# [root@gezi ~]# pvs PV VG Fmt Attr PSize PFree /dev/xvda2 vg1 lvm2 a-- 79.51g 23.62g /dev/xvdb lvm2 --- 250.00g 250.00g [root@gezi ~]# #说明: #If a logical volume contains a physical volume that fails, you cannot use that logical volume. To remove missing physical volumes from a volume group, you can use the --removemissing parameter of the vgreduce command, if there are no logical volumes that are allocated on the missing physical volumes. #来自:Red_Hat_Enterprise_Linux-7-Logical_Volume_Manager_Administration-en-US 4.3.7小节。
二、找回unknown的pv盘
Linux的LVM会默认存储用户对PV/VG/LV的每一步操作,并自动把当前的VG的信息备份到一个文件里面,位置是/etc/lvm/backup/VG名。
这个文件里面记录的东西大概跟vgdisplay/pvdisplay/lvdisplay输出的信息一致,里面也包括了对于恢复VG信息至关重要的PVUUID。
这个文件记录的信息大概就相当于整个VG的元数据,这个文件非常重要,我们就是通过这个文件来恢复整个VG的信息的。(VG卷组centos里面包含的2个PV信息,pv的id device;找到这些信息下面就是通过这些信息来进行恢复;)
[root@localhost]# pvcreate /dev/sda5 -u X4xYDe-VSiw-Gzh3-Ih78-dC08-xBKF-tGWc5s --restorefile /etc/lvm/backup/centos // 使用原来的PV UUID来创建PV,并使用自动备份的文件来恢复信息 [root@localhost]# vgcfgrestore datavg // 恢复datavg的vg信息 [root@localhost]# vgs && pvs && lvs 完事之后激活一下VG卷 root@localhost]vgchange -ay centos