手动部署Ceph集群

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012760435/article/details/89640463

接上篇,这次使用全手工配置的方式部署一套集群。环境配置及需要做的准备工作和上篇一样,不再多说了。先从单节点配起,然后逐步进行扩展,最终做到三节点。

安装Ceph

这里选择从仓库中进行安装,而不是从源代码开始编译,因为实在是太慢了,跑了一天还没跑完。

apt install ceph ceph-mds

配置集群

安装完成之后在/etc/ceph目录下新建文件ceph.conf,内容大致如下,根据实际情况进行修改即可:

fsid = 241da498-6c50-4a44-af7c-7ed3275b0393 #uuid
mon initial members = ceph0                 #主机名
mon host = 172.31.0.5                       #主机地址

#认证相关,不需要修改
auth cluster required = cephx
auth service required = cephx
auth client required = cephx

public network = 172.31.0.0/20              #网络地址

为监控节点创建密钥:

ceph-authtool --create-keyring /etc/ceph/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'

创建client.admin用户并创建密钥:

ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'

创建client.bootstrap-osd用户并创建密钥:

ceph-authtool --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd'

将刚才生成的两个密钥加入ceph.mon.keyring中:

ceph-authtool /etc/ceph/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
ceph-authtool /etc/ceph/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring

此时ceph.mon.keyring中应有如下密钥:
在这里插入图片描述
生成监控映射:

monmaptool --create --add ceph0 172.31.0.5 --fsid 241da498-6c50-4a44-af7c-7ed3275b0393 /etc/ceph/monmap

创建默认的数据目录,其中目录名是{cluster-name}-{hostname}格式:

mkdir /var/lib/ceph/mon/ceph-ceph0

创建守护进程:

ceph-mon --mkfs -i ceph0 --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring

这里有个坑: 官网上写的是sudo -u ceph ceph-mon [--cluster {cluster-name}] --mkfs -i {hostname} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring,但是如果这么敲根本没有响应,要把最前面的【ceph】命令去掉。

启动mon:

ceph-mon -i ceph0 -c /etc/ceph/ceph.conf --cluster ceph

这里有第二个坑!天大的坑! 按照官网上给的systemctl start ceph-mon@node1执行,或者用service ceph start等等执行,通通没有用!只有用ceph-mon启动才可以。这里坑了我一天多,purge了无数遍都没有用,就差给ceph doc提bug了。

如果上面执行正确,此时运行ceph -s应该会正确输出,如下图:
在这里插入图片描述
至此集群已经跑起来了,接下来进行扩展,先从添加osd开始。

猜你喜欢

转载自blog.csdn.net/u012760435/article/details/89640463
今日推荐