1、客户端上安装ceph-common(会自动安装rbdmap服务)
yum install ceph-common #centos7默认是ceph10版本
apt install ceph-common #ubuntu22默认是ceph17版本
2、创建访问用户(或者直接使用admin账户)
#创建一个名为general_mount的普通用户,并给其授权访问名为volumes的池
ceph auth get-or-create client.general_mount mon 'profile rbd' osd 'profile rbd pool=volumes' mgr 'profile rbd pool=volumes'
#导出信息为文件
ceph auth get-or-create client.general_mount -o ceph.client.general_mount.keyring
将/etc/ceph/ceph.conf 和 ceph.client.general_mount.keyring文件拷贝到客户端/etc/ceph/目录下 (客户端可能需要先安装ceph-common)
3、客户端远程挂载volumes/kvm005-system
#远程挂载
rbd map volumes/kvm005-system --id general_mount
#rbd map volumes/kvm005-system
#格式化并挂载使用(推荐使用名字的格式化,不使用rbd0这种避免多个盘格式错了)
#mkfs.xfs /dev/rbd0
mkfs.xfs /dev/rbd/volumes/kvm005-system
#mkfs.ext4 -m0 /dev/rbd/volumes/kvm005-system
#挂载推荐使用如下方式(不使用rbd0这种)
mount /dev/rbd/volumes/kvm005-system /tmp/
#mount /dev/rbd0 /tmp
4、客户端实现开机自动挂载rbd块设备
#编辑rbdmap服务配置文件/etc/ceph/rbdmap,写入如下信息
#echo "volumes/kvm005-system id=admin,keyring=/etc/ceph/ceph.client.admin.keyring" >> /etc/ceph/rbdmap
echo "volumes/kvm005-system id=general_mount,keyring=/etc/ceph/ceph.client.general_mount.keyring" >> /etc/ceph/rbdmap
#设置开机自启动
systemctl enable rbdmap
#修改/etc/fstab文件
echo "/dev/rbd/volumes/kvm005-system /tmp xfs noauto 0 0" >>/etc/fstab
#echo "/dev/rbd0 /tmp xfs defaults,noatime,_netdev 0 0" >>/etc/fstab
#检查两个文件(/etc/ceph/rbdmap、/etc/fstab)是否有误后,重启主机测试
如果文章对你有帮助,欢迎点击上方按钮打赏作者
暂无评论