天天看点

docker笔记45-客户端映射ceph的rbd块设备 ceph rbd客户端要求 安装ceph rbd客户端 将ceph服务端的秘钥环拷贝到ceph的客户端 在ceph客户端查看rbd 映射rbd到客户端并且挂载使用 

ceph rbd客户端要求

客户端系统内核 2.6.32以上

另外,我这个环境中把k9s-master1当做ceph客户端,而服务端是k8s-node1。

安装ceph rbd客户端

[[email protected] ~]# yum search ceph
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.aliyun.com
========================================================= N/S matched: ceph =========================================================
centos-release-ceph-hammer.noarch : Ceph Hammer packages from the CentOS Storage SIG repository
centos-release-ceph-jewel.noarch : Ceph Jewel packages from the CentOS Storage SIG repository
centos-release-ceph-luminous.noarch : Ceph Luminous packages from the CentOS Storage SIG repository
ceph-common.x86_64 : Ceph Common
           
[[email protected] ~]# yum -y install centos-release-ceph-luminous.noarch
           
[[email protected] ~]# yum -y install ceph
           

将ceph服务端的秘钥环拷贝到ceph的客户端

    生产中不要拷贝秘钥环,而是创建一个用户,并赋予相应的权限。

    我这里拷贝秘钥环是为了方便。

    登录ceph服务器集群中的任何一点,将其秘钥环拷贝到ceph的客户端。

[[email protected] ~]# cd /etc/ceph/
[[email protected] ceph]# scp ceph.conf 172.16.22.197:/etc/ceph/
[[email protected] ceph]# scp ceph.client.admin.keyring 172.16.22.197:/etc/ceph/
           

在ceph客户端查看rbd

[[email protected] ~]# rbd --image data info
rbd image 'data':
size 1024 MB in 256 objects
order 22 (4096 kB objects)
block_name_prefix: rbd_data.1149238e1f29
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
flags:
           

    输出如上信息,表明我们可以使用rbd。

映射rbd到客户端并且挂载使用 

    映射rbd到客户端并且挂载使用 rbd map  rbd/data 

[[email protected] ~]# rbd map rbd/data  ##rbd是pool的名字,data是块存储的名字
rbd: sysfs write failed
RBD image feature set mismatch. Try disabling features unsupported by the kernel with "rbd feature disable".
In some cases useful info is found in syslog - try "dmesg | tail".
rbd: map failed: (6) No such device or address
           

    看到上面报错了,我们需要执行一下如下命令:

[[email protected] ~]# rbd  feature disable   rbd/data   exclusive-lock object-map fast-diff deep-flatten
           
[[email protected] ~]# rbd map rbd/data 
/dev/rbd0
           
[[email protected] ~]# fdisk -l
Disk /dev/rbd0: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4194304 bytes / 4194304 bytes
           

    看到,我们把ceph的rdb块设备挂载到了k9s-master1机器上了。

    这时候,/dev/rdb0还是一个裸设备,下面我们格式化一下它,给它创建一个文件系统。

[[email protected] ~]# mkfs.ext4 /dev/rbd0
           

    挂载到/mnt下面:

[[email protected] ~]# mount /dev/rbd0 /mnt/
           

    这样,我们就可以使用rbd块设备了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28916011/viewspace-2218639/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28916011/viewspace-2218639/