问题

pvcreate 命令在使用多路径设备时失败,即使该设备存在,也会出现以下错误。

# fdisk -l /dev/mapper/mpatha
Disk /dev/mapper/mpatha: 51.6 GB, 51624542208 bytes, 100829184 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x5d7fc634
Device Boot Start End Blocks Id System
/dev/mapper/mpatha1 32 100829183 50414576 83 Linux
# pvcreate /dev/mapper/mpatha
Device /dev/mapper/mpatha not found (or ignored by filtering). 《--- 未找到设备 /dev/mapper/mpatha(或者被过滤忽略)。

该错误通常发生在 /etc/lvm/lvm.conf 具有错误的过滤器部分或者尝试用作 PV 的设备已经具有底层分区时。
根据情况使用下面描述的任一解决方案。

更多: zhilu jiaocheng

解决方案 1:验证 /etc/lvm/lvm.conf 中的过滤器设置

  1. 验证 /etc/lvm/lvm.conf 中的过滤器设置并确保它允许扫描多路径设备。
    在本地 SCSI 存储和设备映射器多路径 SAN 存储上具有 LVM 设备的系统可能定义:
# cat /etc/lvm/lvm.conf
filter = [ "a|^/dev/sda[1-9]$|", "a|^/dev/mapper/*|", "r|^/dev/*|" ]
  1. 在多路径设备上使用多路径设备 /dev/mapper/mpatha 和 pvcreate。
# pvcreate /dev/mapper/mpatha
Physical volume "/dev/mapper/mpatha" successfully created

解决方案 2:删除现有分区(如果有)

第二种解决方案是实际验证尝试用作 PV 的设备是否不包含任何底层分区。
在下面的例子中,多路径磁盘 mpatha 有一个分区 mpatha1,如下所示。

# fdisk -l /dev/mapper/mpatha
Disk /dev/mapper/mpatha: 51.6 GB, 51624542208 bytes, 100829184 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x5d7fc634
Device Boot Start End Blocks Id System
/dev/mapper/mpatha1 32 100829183 50414576 83 Linux          <-----------

如上所述,请在之后通过发出 fdisk 命令删除尝试作为 PV 的设备上的任何底层分区,请重试 pvcreate。

# fdisk /dev/mapper/mpatha
Disk /dev/mapper/mpatha: 51.6 GB, 51624542208 bytes, 100829184 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x5d7fc634
Device Boot Start End Blocks Id System
/dev/mapper/mpatha1 32 100829183 50414576 83 Linux
Command (m for help): d
Partition number (1-4): 1
Command (m for help): w
# pvcreate /dev/mapper/mpatha
Physical volume "/dev/mapper/mpatha" successfully created
pvcreate 报错: Device /dev/mapper/mpatha Not Found
日期:2020-09-17 00:14:05 来源:oir作者:oir