学习ceph官网的ceph块设备命令(一)

一)存储池命令
1.列出存储池
#ceph osd lspools
#ceph osd pool ls
2.创建存储池
# ceph osd pool create yhcpool 512
pool 'yhcpool' created
# ceph osd pool ls
rbd
yhcpool
二)块设备基本命令
1.创建块设备映像
#rbd create --size 1024 yhcpool/yhctest
2.查看块设备
# rbd ls --pool yhcpool
yhctest
3.查看镜像信息
# rbd info yhcpool/yhctest
rbd image 'yhctest':
size 1024 MB in 256 objects
order 22 (4096 kB objects)
block_name_prefix: rbd_data.3999c238e1f29
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
flags:
4. 调整块设备镜像大小
4.1扩容块设备镜像
# rbd resize --size 2048 yhcpool/yhctest
Resizing image: 100% complete...done.
# rbd info yhcpool/yhctest
rbd image 'yhctest':
size 2048 MB in 512 objects
order 22 (4096 kB objects)
block_name_prefix: rbd_data.3999c238e1f29
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
flags:
4.2缩容块设备镜像
# rbd resize --size 512 --allow-shrink yhcpool/yhctest
Resizing image: 100% complete...done.
# rbd info yhcpool/yhctest
rbd image 'yhctest':
size 512 MB in 128 objects
order 22 (4096 kB objects)
block_name_prefix: rbd_data.3999c238e1f29
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
flags:
5.删除块设备映像
# rbd rm yhctest
Removing image: 100% complete...done.
三)rbd内核命令
1.获取rbd镜像列表
# rbd list --pool yhcpool
yhctest
2.映射块设备(出现问题
# rbd map yhcpool/yhctest
rbd: sysfs write failed
RBD image feature set mismatch. You can disable features unsupported by the kernel with "rbd feature disable".
In some cases useful info is found in syslog - try "dmesg | tail" or so.
rbd: map failed: (6) No such device or address
原因:
由于南京osp的ceph安装的是Jewel(10.2.3),而操作系统安装的是centos7.2,内核版本为3.10.0-327.36.2.el7.x86_64,根据报错内容提示可知,服务器系统内核版 ,不支持有些格式2 的新特性导致。
可以使用 
--image-feature   选项指定使用特性,不用全部开启。我们的需求仅需要使用快照等特性,开启layering即可,配置方式如下:
rbd create rbd/test1 --size 10G --image-format 2 --image-feature  layering
rbd ls
rbd map rbd/test1   #可以正常映射;
#经测试,内核版本 3.10,仅支持此特性(layering),其它特性需要使用更高版本内核,或者从新编译内核加载特性模块才行。
# ceph -v
ceph version 10.2.3 (ecc23778eb545d8dd55e2e4735b53cc93f92e65b)
# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.2.1511 (Core)
Release: 7.2.1511
Codename: Core
# uname -a
Linux ceph1 3.10.0-327.36.2.el7.x86_64 #1 SMP Mon Oct 10 23:08:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
3.查看已映射块设备
# rbd showmapped
id pool image snap device
0 yhcpool test1 - /dev/rbd0
4.取消块设备映射
# rbd showmapped
id pool image snap device
0 yhcpool test1 - /dev/rbd0
[root@ceph1 ~]# rbd unmap yhcpool/test1
[root@ceph1 ~]# rbd showmapped
posted @ 2017-01-03 15:22  蓝色的海008  阅读(1435)  评论(0)    收藏  举报