cli
# rbd --namespace $namespace $command $pool/$image # rbd $command $pool/$namespace/$image
create
[root@ceph-1:~/ceph-cluster]# rbd namespace ls ceph-rbd --format=json [] [root@ceph-1:~/ceph-cluster]# rbd namespace create ceph-rbd/ns1 [root@ceph-1:~/ceph-cluster]# rbd namespace ls ceph-rbd --format=json [{"name":"ns1"}] [root@ceph-1:~/ceph-cluster]# rbd create ceph-rbd/ns1/rbd-image1.img --size 1024 [root@ceph-1:~/ceph-cluster]# rbd ls ceph-rbd --long NAME SIZE PARENT FMT PROT LOCK rbd-image.img 1 GiB 2 [root@ceph-1:~/ceph-cluster]# rbd ls ceph-rbd/ns1 --long NAME SIZE PARENT FMT PROT LOCK rbd-image1.img 1 GiB 2
rbd map on centos 7 (1810)
[root@ceph-1:~/ceph-cluster]# rbd map ceph-rbd/ns1/rbd-image1.img rbd: sysfs write failed In some cases useful info is found in syslog - try "dmesg | tail". rbd: map failed: (22) Invalid argument [root@ceph-1:~/ceph-cluster]# dmesg |tail [......] [18427.446585] rbd: rbd0: capacity 1073741824 features 0x5 [24449.735082] libceph: bad option at '_pool_ns=ns1'
To map a rbd (+ namespace) you need a kernel >=
with > 5.0 kernel (
[root@ceph-1:~/ceph-cluster]# rbd info ceph-rbd/ns1/rbd-image1.img rbd image 'rbd-image1.img': size 1 GiB in 256 objects order 22 (4 MiB objects) snapshot_count: 0 id: 25c26241ea4ac block_name_prefix: rbd_data.25c26241ea4ac format: 2 features: layering, exclusive-lock, object-map, fast-diff, deep-flatten op_features: flags: create_timestamp: Wed Feb 3 15:57:13 2021 access_timestamp: Wed Feb 3 15:57:13 2021 modify_timestamp: Wed Feb 3 15:57:13 2021 [root@ceph-1:~/ceph-cluster]# rbd feature disable ceph-rbd/ns1/rbd-image1.img deep-flatten [root@ceph-1:~/ceph-cluster]# rbd feature disable ceph-rbd/ns1/rbd-image1.img fast-diff [root@ceph-1:~/ceph-cluster]# rbd device map ceph-rbd/ns1/rbd-image1.img /dev/rbd0 [root@ceph-1:~/ceph-cluster]# rbd showmapped id pool namespace image snap device 0 rbd ns1 rbd-image1.img - /dev/rbd0 [root@ceph-1:~/ceph-cluster]# uname -ar Linux ceph-1 5.5.6-1.el7.elrepo.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux [root@ceph-1:~/ceph-cluster]# rbd device unmap /dev/rbd0 [root@ceph-1:~/ceph-cluster]# rbd rm ceph-rbd/ns1/rbd-image1.img [root@ceph-1:~/ceph-cluster]# rbd namespace remove ceph-rbd/ns1
cephx
[root@ceph-1:~/ceph-cluster]# ceph auth get-or-create client.$name mon 'profile rbd' osd 'profile rbd namespace=$namespace' and go: [root@ceph-1:~/ceph-cluster]# ls /etc/ceph/ceph.client.$name.keyring /etc/ceph/ceph.client.$name.keyring [root@ceph-1:~/ceph-cluster]# rbd -n client.$name ls images: (1) Operation not permitted rbd: listing images failed: (1) Operation not permitted [root@ceph-1:~/ceph-cluster]# rbd -n client.$name ls --namespace=ns1 rbd-image1.img
参考链接
https://blog.devnu11.net/2019/10/ceph-rbd-namespaced.html