ceph的quincy是ceph的第17个版本,初始发行时间是2022-04-19,本文将通过cephadm工具来搭建quincy的集群。
在以前吴昊的文章中写过octopus版本的搭建教程https://blog.whsir.com/post-6697.html,总体来说quincy版本和octopus区别并不是很大。
规划
三台Rocky Linux 8.7服务器,4核CPU,4G内存,根磁盘50GB,数据盘一个100GB(磁盘无需初始化操作,fdisk -l中可见即可)
1 2 3 |
10.10.10.161 ceph1 10.10.10.162 ceph2 10.10.10.163 ceph3 |
关闭firewalld和selinux,或自行放通
1 2 3 4 |
systemctl stop firewalld systemctl disable firewalld setenforce 0 sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config |
以下1~7步分别在三台节点中执行
1、同步时间
如果你想使用传统的ntpdate同步时间,可参考https://www.wlnmp.com/post-664.html
建议使用新的时间同步方式chrony,此处不做过多说明,时间同步都不会,后面的教程你也搞不定!
2、分别对应修改三台机器hostname
1 2 3 |
hostnamectl set-hostname ceph1 hostnamectl set-hostname ceph2 hostnamectl set-hostname ceph3 |
3、在三台机器分别添加配置hosts
1 2 3 |
10.10.10.161 ceph1 10.10.10.162 ceph2 10.10.10.163 ceph3 |
4、在三台机器分别安装配置docker
下载所需容器及所需rpm包,并上传到服务器上,进行安装,这里离线rpm包docker-ce版本是docker-ce-23.0.4。
相关包下载地址(下载较慢可通过第三方工具,如迅雷):
https://down.whsir.com/downloads/registry2.tar
https://down.whsir.com/downloads/packages_1.tar.gz
https://down.whsir.com/downloads/packages_2.tar.gz
https://down.whsir.com/downloads/packages_3.tar.gz
https://down.whsir.com/downloads/ceph17_packages.tar.gz
注意我这里是Rocky Linux 8.7版本,所以这几个tar.gz的包是基于8.7这个版本提取验证通过的,你在安装的时候可能会出现依赖相关问题,你也可以考虑自建个内网源来解决rpm包安装,以及依赖的问题,这一步如果搞不定,后面的也不用看了,因为这是最基础的。
1 2 3 4 5 6 7 |
tar xf packages_1.tar.gz tar xf packages_2.tar.gz tar xf packages_3.tar.gz mkdir /etc/yum.repos.d/repo.bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo.bak dnf install packages_1/*.rpm dnf install packages_2/*.rpm dnf install packages_3/*.rpm |
5、启动docker
1 |
systemctl enable docker && systemctl start docker |
6、导入离线包
1 |
tar xf ceph17_packages.tar.gz |
方法一(推荐):通过for循环批量导入
1 |
for i in `ls ceph17_packages`;do docker load -i ceph17_packages/$i;done |
方法二:一个一个的导入
1 2 3 4 5 |
docker load < ceph17_packages/ceph_v17.tar docker load < ceph17_packages/ceph-grafana_8.3.5.tar docker load < ceph17_packages/node-exporter_v1.3.1.tar docker load < ceph17_packages/prometheus_v2.33.4.tar docker load < ceph17_packages/alertmanager_v0.23.0.tar |
7、配置私有仓库地址
注意,三台节点全部都是这么配置
1 2 3 4 5 6 7 |
cat >> /etc/docker/daemon.json << EOF { "insecure-registries":["10.10.10.161:5000"] } EOF systemctl daemon-reload systemctl restart docker |
以下内容仅在ceph1中执行
8、导入私有仓库镜像
1 |
docker load -i registry2.tar |
9、启动私有仓库
1 |
docker run -d -p 5000:5000 -v /var/lib/registry:/var/lib/registry --restart=always --name registry IMAGE ID |
例如:通过docker images,可以看到我这里的registry的IMAGE ID是8db46f9d7550,那么就执行以下命令
1 |
docker run -d -p 5000:5000 -v /var/lib/registry:/var/lib/registry --restart=always --name registry 8db46f9d7550 |
10、ceph镜像打标签推送到仓库
1 2 |
docker tag quay.io/ceph/ceph:v17 10.10.10.161:5000/ceph:v17 docker push 10.10.10.161:5000/ceph:v17 |
11、离线引导集群
1 |
cephadm --image 10.10.10.161:5000/ceph:v17 bootstrap --mon-ip 10.10.10.161 --skip-pull |
12、查看ceph集群容器所有组件运行状态
1 |
ceph orch ps |
确保这8个STATUS状态全部是running
如果想重启某个NAME,可使用该命令:ceph orch daemon restart NAME
如果想强制删除重建某个NAME,可使用该命令:ceph orch daemon rm NAME --force
1 |
ceph orch ls |
13、拷贝密钥到另外两台主机上
1 |
ssh-copy-id -f -i /etc/ceph/ceph.pub root@ceph2 |
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/ceph/ceph.pub"
The authenticity of host 'ceph2 (10.10.10.162)' can't be established.
ECDSA key fingerprint is SHA256:NACCfHC7r8oVTOGwn3zgp0/iShcjxdfPdWU/xe9n3qc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
root@ceph2's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@ceph2'"
and check to make sure that only the key(s) you wanted were added.
1 |
ssh-copy-id -f -i /etc/ceph/ceph.pub root@ceph3 |
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/ceph/ceph.pub"
The authenticity of host 'ceph3 (10.10.10.163)' can't be established.
ECDSA key fingerprint is SHA256:NACCfHC7r8oVTOGwn3zgp0/iShcjxdfPdWU/xe9n3qc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
root@ceph3's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@ceph3'"
and check to make sure that only the key(s) you wanted were added.
14、将另外两个主机添加至集群中
1 |
ceph orch host add ceph2 10.10.10.162 |
Added host 'ceph2' with addr '10.10.10.162'
1 |
ceph orch host add ceph3 10.10.10.163 |
Added host 'ceph3' with addr '10.10.10.163'
15、查看主机相关状态
1 |
ceph orch host ls |
HOST ADDR LABELS STATUS
ceph1 10.10.10.161 _admin
ceph2 10.10.10.162
ceph3 10.10.10.163
3 hosts in cluster
1 |
ceph orch ps |
确保STATUS状态全部是running,再进行下一步
1 |
ceph orch ls |
16、创建OSD
方法一(推荐):自动添加所有满足条件的OSD
1 |
ceph orch apply osd --all-available-devices |
方法二:手工指定的方式添加OSD
1 2 3 |
ceph orch daemon add osd ceph1:/dev/vdb ceph orch daemon add osd ceph2:/dev/vdb ceph orch daemon add osd ceph3:/dev/vdb |
稍等片刻,通过命令检查,Available显示no,表示OSD创建完成
1 |
ceph orch device ls |
此时通过仪表盘可看到集群正常
通过命令看下集群状态正常
1 |
ceph -s |
至此ceph version 17.2.6 quincy(stable)集群部署完成
附、一些命令补充
关闭仪表盘https证书认证
1 |
ceph config set mgr mgr/dashboard/ssl false |
修改http的端口号
1 |
ceph config set mgr mgr/dashboard/server_port 9333 |
修改https的端口号
1 |
ceph config set mgr mgr/dashboard/ssl_server_port 9333 |
修改仪表盘默认的监听地址
1 |
ceph config set mgr mgr/dashboard/server_addr 0.0.0.0 |
修改上面所有的内容,都需要重启仪表盘(dashboard)生效
1 2 |
ceph mgr module disable dashboard ceph mgr module enable dashboard |
原文链接:cephadm搭建Ceph集群(离线安装quincy版),转载请注明来源!
10.10.10.161 ceph2
10.10.10.162 ceph2
10.10.10.163 ceph3
发现一处错误
还真的是打错了,感谢反馈