Ceph块设备对RBD块设备操作LVM创建PV时报错

Ceph块设备 对RBD块设备操作LVM创建PV时报错

当映射好了RBD映像中后,要在其上创建LVM逻辑卷,在执行pvcreate时出错。报错如下:

1
2
3
[root@ceph-master ceph]# pvcreate /dev/rbd0
/dev/sdd: open failed: No medium found
Device /dev/rbd0 excluded by a filter.

可以看到执行创建PV时被过滤器拦截掉了,这是因为默认情况下LVM不支持rbd设备类型,那么在LVM过滤器配置中手动添加RBD类型即可。

调试模式查看详细信息:

1
2
3
4
5
# pvcreate -vvvv /dev/rbd0 &> /tmp/out
# less /tmp/out
....
#filters/filter-type.c:27 /dev/rbd0: Skipping: Unrecognised LVM device type 252
....

查看设备类型ID

cat /proc/devices

可以找到rbd设备类型ID编号为252,记住它后接下来在LVM过滤器配置文件中添加它。

修改LVM过滤器配置文件

vim /etc/lvm/lvm.conf

找到types参数,将rbd和252修改为如下配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
# Configuration section devices.
# How LVM uses block devices.
devices {
...
# Configuration option devices/types.
# List of additional acceptable block device types.
# These are of device type names from /proc/devices, followed by the
# maximum number of partitions.
#
# Example
types = [ "rbd", 252 ]
#
# This configuration option is advanced.
# This configuration option does not have a default value defined.
...

现在尝试重新添加rbd设备作为PV:

pvcreate /dev/rbd0

现在可以成功在RBD块设备上执行创建PV操作了。