在尝试扩展VG时,产生了以下错误信息:
[root@yunweixia.com ~]# vgextend example_vg /dev/mapper/mpatha Error vgextend : Cannot use device /dev/mapper/mpatha with duplicates. WARNING: Not using lvmetad because duplicate PVs were found. WARNING: Use multipath or vgimportclone to resolve duplicate PVs? WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad. WARNING: PV xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx on /dev/sdx was already found on /dev/sdy. WARNING: PV xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx on /dev/sdy was already found on /dev/sdz. WARNING: PV xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx on /dev/sdz was already found on /dev/mapper/mpatha. <...>
查看/etc/lvm/lvm.conf的过滤规则,如下所示:
# Example # Accept every block device: #filter = [ "a|.*/|" ] # Reject the cdrom drive: # filter = [ "r|/dev/cdrom|" ] # Work with just loopback devices, e.g. for testing: # filter = [ "a|loop|", "r|.*|" ] # Accept all loop devices and ide drives except hdc: # filter = [ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ] # Use anchors to be very specific: # filter = [ "a|^/dev/hda8$|", "r|.*/|" ] # # This configuration option has an automatic default value. # filter = [ "a|.*/|" ] # Configuration option devices/global_filter. # Limit the block devices that are used by LVM system components. # Because devices/filter may be overridden from the command line, it is # not suitable for system-wide device filtering, e.g. udev and lvmetad. # Use global_filter to hide devices from these LVM system components. # The syntax is the same as devices/filter. Devices rejected by # global_filter are not opened by LVM. # This configuration option has an automatic default value. # global_filter = [ "a|.*/|" ]
如果没有适当的过滤规则,那么lvm.conf文件将默认接受所有设备:
# This configuration option has an automatic default value. # filter = [ "a|.*/|" ]
解决方案
解决该问题需要设置自定义过滤规则/etc/lvm/lvm.conf,包括全局过滤规则。
一、设置过滤规则
如下所示:
filter = [ "a|^/dev/sda5$|", "a|/dev/emcpower.*|", "r|.*|" ] global_filter = [ "a|^/dev/sda5$|, "a|/dev/emcpower.*|", "r|.*|" ]
扩展阅读
该过滤规则由三部分组成的:
1. a|^/dev/sda5$|:包含设备文件 /dev/sda5。
2. a|/dev/emcpower.*|:包含设备文件名以/dev/emcpower开头的所有设备,比如 /dev/emcpowera、/dev/emcpowerb 等。
3. r|.*|:排除其余的所有文件,即排除其他所有设备文件(排除了前两部分所未涉及到的设备)。
这些过滤规则的作用是将指定的磁盘设备排除在LVM的控制范围之外,从而确保LVM只操作符合规则的设备,确保系统的稳定性和数据安全。
二、生效过滤规则
想要过滤规则生效,initramfs将需要重建。然后更新LVM缓存并再次尝试执行vgextend命令。
[root@yunweixia.com ~]# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak [root@yunweixia.com ~]# dracut -f -v [root@yunweixia.com ~]# pvscan --cache
[/content_hide]
原创文章,作者:运维侠,如若转载,请注明出处:https://www.yunweixia.com/solutions/lvm-resize-cannot-use-device-with-duplicates-solution.html