使用 cephadm 安装 Ceph 集群
centos7.4三台
Ceph octopus 15.2.3
Python 3.6
Docker 默认最新的
注意:OSD 硬盘需要大于 5G
官方文档:
https://docs.ceph.com/docs/master/cephadm/install/
准备工作:
-
配置定义Ceph所有节点HostName:
hostnamectl set-hostname ceph1
hostnamectl set-hostname ceph2
hostnamectl set-hostname ceph3 -
配置Host文件:
ceph1 10.1.6.90
ceph2 10.1.6.91
ceph3 10.1.6.92 -
三台主机配置时间同步服务:
在所有 Ceph 节点上安装并运行chrony服务,特别是监控节点以免因时钟漂移导致故障 -
安装依赖:
yum -y install python3 yum-utils -
安装Docker服务
cephadm基于容器运行所有ceph组件,所有节点需要安装docker或podman,这里以安装docker为例。
配置阿里云yum源
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
或:清华大学源
yum-config-manager \
--add-repo \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
for i in `tail -n 4 /etc/hosts | awk '{print $1}'`; do ssh $i exec yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -y ;done
for i in `tail -n 4 /etc/hosts | awk '{print $1}'`; do ssh $i exec yum clear all;yum makecache ;done
安装 Docker Engine-Community 和 containerd
yum install docker-ce docker-ce-cli containerd.io -y
for i in `tail -n 4 /etc/hosts | awk '{print $1}'`; do ssh $i exec yum install docker-ce docker-ce-cli containerd.io -y ;done
配置docker镜像加速
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF
Docker中国区官方镜像
https://registry.docker-cn.com
网易
http://hub-mirror.c.163.com
中国科技大学
https://docker.mirrors.ustc.edu.cn
for i in `tail -n 4 /etc/hosts | awk '{print $1}'`; do scp /etc/docker/daemon.json $i:/etc/docker/daemon.json ;done
启动docker服务
systemctl start docker
systemctl enable docker
systemctl daemon-reload
systemctl restart docker
- 关闭防火墙及selinux
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
关闭selinux
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
- 配置三台主机免交互
ssh-keygen
ssh-copy-id root@ceph1
ssh-copy-id root@ceph2
ssh-copy-id root@ceph3
- 更新yum 源
//安装wget命令,方便下载新的yum源。
yum install wget -y
//备份原yum
cd /etc/yum.repos.d/
mkdir backup
mv C* backup
//用wget命令下载新的yum源。
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
//配置ceph源
vi /etc/yum.repos.d/ceph.repo
[ceph]
name=Ceph packages for
baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[ceph-noarch]
name=Ceph noarch packages
baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/noarch/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages
baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/SRPMS/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
yum 时候出现Another app is currently holding the yum lock; waiting for it to exit...解决方法
rm -rf /var/run/yum.pid
安装cephadm
wget https://github.com/ceph/ceph/raw/octopus/src/cephadm/cephadm
或者直接从github下载
curl https://raw.githubusercontent.com/ceph/ceph/v15.2.13/src/cephadm/cephadm -o cephadm
再不济你把代码复制下来给执行权限: chmod a+x cephadm && cp cephadm