1.创建pool
创建pool时,ceph会使用默认值,但是建议设置池的副本大小、布局组的默认数量。设置的方式,①运行pool命令时指定②修改ceph.conf 中配置
osd pool default pg num = 256
osd pool default pgp num = 256
ceph osd pool create {pool-name} {pg-num}{pgp-num}
2.查看pool列表
ceph osd lspools
3.创建image
rbd create --size {字节大小 如10G} {pool-name}/{image-name}
4.查询image信息
rbd ls {pool-name} #列而pool中的image
rbd info {pool-name}/ {image-name} #列出image的详细信息
5.调整image的大小
rbd resize --size 30G {pool-name}/{image-name} #(to increase)
rbd resize --size 20G {pool-name}/{image-name} --allow-shrink #(to decrease)
6.删除设备影响
rbd rm {pool-name}/{image-name} #从pool中删除image
7.块设备移动到垃圾桶
rbd trash mv {pool-name}/{image-name}
8.从垃圾桶中删除块设备
rbd trash rm {pool-name}/{image-id} #一个有快照或者正在被克隆使用的块设备可以移动到垃圾桶,但不允许在垃圾桶中删除
9.从垃圾桶中恢复块设备
rbd trash restore {image-id} # 可以通过 rbd trash ls {pool-name} 查询已经删除的images的id
10.映射块设备到内核
rbd device map {pool-name}/{image-name} --id admin
注意:如果报错如下,可以通过 dmesg 查看错误提示信息
RBD image feature set mismatch. You can disable features unsupported by the kernel with "rbd feature disable ceph-demo/rbd-demo.img object-map fast-diff deep-flatten".
In some cases useful info is found in syslog - try "dmesg | tail".
rbd: map failed: (6) No such device or address
解决方法:
rbd feature disable ceph-demo/rbd-demo.img object-map fast-diff deep-flatten
11.取消块设备映射
rbd device unmap /dev/rbd/{pool-name}/{image-name}