cephadm新的CEPH集群
Cephadm通过在单个主机上“引导”创建一个新的Ceph集群,将集群扩展到包含任何其他主机,然后部署所需的服务。
先决要求:这些环境,安装docker-ce,和chrony时钟同步时会安装。如未安装可以手动安装。
- Python 3
- Systemd
- Podman or Docker for running containers
- Time synchronization (such as chrony or NTP)
- LVM2 for provisioning storage devices
测试环境:
系统为: ubantu:22.10
任何现代的Linux发行版都应该足够了。依赖项由下面的引导进程自动安装。
主机名 | IP地址 | cpu | 内存 | 磁盘 |
---|---|---|---|---|
node1 | 172.16.11.135 | 2 | 4G | 2块 |
node2 | 172.16.11.136 | 2 | 4G | 2块 |
node3 | 172.16.11.137 | 2 | 4G | 2块 |
准备工作
以下所有主机配置
配置主机名
hostnamectl set-hostname node1
配置主机hosts
root@node1:~# vim /etc/hosts
127.0.0.1 localhost
172.16.11.135 node1
172.16.11.136 node2
172.16.11.137 node3
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
~
安装配置时间同步
配置时区:
root@node1:/etc/chrony# timedatectl set-timezone Asia/Shanghai
安装配置时间同步工具
root@node3:~# apt-get -y install chrony
Reading package lists... Done
root@node3:~# systemctl enable chrony --now
Synchronizing state of chrony.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable chrony
修改时间同步服务器
ceph 默认要求时钟偏差50ms以下
需要写成 minpoll 1 maxpoll 1
不然安装后会有告警信息:clock skew detected on mon.node2, mon.node3 ,当然也可以修改默认时钟偏差。
root@node3:~# vim /etc/chrony/chrony.conf
confdir /etc/chrony/conf.d
#pool ntp.ubuntu.com iburst maxsources 4
#pool 0.ubuntu.pool.ntp.org iburst maxsources 1
#pool 1.ubuntu.pool.ntp.org iburst maxsources 1
#pool 2.ubuntu.pool.ntp.org iburst maxsources 2
server ntp.aliyun.com iburst minpoll 1 maxpoll 1
重启服务
root@node3:~# systemctl restart chrony
立即同步时间
root@node3:~# chronyc -a makestep
200 OK
查看时间同步源:
$ chronyc sources -v
立即手工同步
$chronyc -a makestep
查看时间同步源状态:
$ chronyc sourcestats -v
设置硬件时间
硬件时间默认为UTC:
$ timedatectl set-local-rtc 1
启用NTP时间同步:
$ timedatectl set-ntp yes
校准时间服务器:
$ chronyc tracking
最后需要注意的是,配置完/etc/chrony.conf后,需重启chrony服务,否则可能会不生效。
安装docker
这里用阿里开源镜像,安装最新版,或者选择版本安装
# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce
# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# apt-cache madison docker-ce
# docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# Step 2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]
安装后报错
修复过程
root@node3:~# apt-get remove docker-ce -y
root@node3:~# apt-get -y install docker-ce
root@node3:~# systemctl start docker
root@node3:~# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Mon 2023-05-22 01:29:57 UTC; 13s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 5472 (dockerd)
Tasks: 9
Memory: 24.7M
CPU: 489ms
CGroup: /system.slice/docker.service
└─5472 /usr/bin/dockerd -H fd:// --containerd=/run/containerd