cephadm方式安装ceph集群
服务器规划
centos7.9
docker-v20.10.17
ceph1 ceph2 ceph3 ceph4 ceph5
磁盘:2T*3=6T(共30T)
内存、cpu | 磁盘 | 操作系统 |
8核8g | 2T*3 | centos7.9 |
8核8g | 2T*3 | centos7.9 |
8核8g | 2T*3 | centos7.9 |
8核8g | 2T*3 | centos7.9 |
8核8g | 2T*3 | centos7.9 |
[root@ceph1 ~]# ssh-keygen
[root@ceph1 ~]# for i in ceph{1..5}; do echo ">>> $i";ssh-copy-id root@$i;done
[root@ceph1 ~]# wget https://github.com/ceph/ceph/raw/v15.2.17/src/cephadm/cephadm
[root@ceph1 ~]# chmod +x cephadm #这里提前下载,脚本里的已注释掉
cat > ceph-v15.2.17.sh << 'eof'
#!/bin/bash
ceph1_ip=192.168.1.204
# 0、centos7.9安装Python3
echo -e "\e[32;5m[=====♫ ♬ ♪ ♩ ♭ ♪ の 安装 Python3 の ♪ ♭ ♩ ♪ ♬ ♫=====]\e[0m"
for i in $@;do
echo -e "\e[32;5m>>> $i\e[0m";
ssh root@$i "yum install python3 -y";
done
# 1、安装 docker
echo -e "\e[32;5m[=====♫ ♬ ♪ ♩ ♭ ♪ の 安装 docker の ♪ ♭ ♩ ♪ ♬ ♫=====]\e[0m"
# 华为源
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+repo.huaweicloud.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
for i in ${@:2};do
echo -e "\e[32;5m>>> $i\e[0m";
scp /etc/yum.repos.d/docker-ce.repo root@$i:/etc/yum.repos.d;
done
for i in $@;do
echo -e "\e[32;5m>>> $i\e[0m";
ssh root@$i "yum makecache fast && yum install docker-ce -y";
done
for i in $@;do
echo -e "\e[32;5m>>> $i\e[0m";
ssh root@$i "systemctl enable docker --now";
done
# 2、cephadm-v15.2.17安装ceph集群
echo -e "\e[32;5m[=====♫ ♬ ♪ ♩ ♭ ♪ の cephadm-v15.2.17安装ceph集群 の ♪ ♭ ♩ ♪ ♬ ♫=====]\e[0m"
# wget https://github.com/ceph/ceph/raw/v15.2.17/src/cephadm/cephadm
# 查看镜像
grep quay.io cephadm |awk '{print $3}' |grep -n '.*'
# 下载镜像
grep quay.io cephadm |awk '{print $3}' |xargs -i docker pull {}
docker save -o ceph-v15.tar quay.io/ceph/ceph:v15
for i in ${@:2}; do echo ">>> $i";scp /root/ceph-v15.tar root@$i:/root; done
for i in ${@:2}; do echo ">>> $i";ssh root@$i "ls /root/ceph-v15.tar |xargs -i docker load -i {}";done
./cephadm bootstrap --mon-ip $ceph1_ip | tee ceph-init.log
# ./cephadm add-repo --release octopus
./cephadm add-repo --release 15.2.17
yum install ceph-common -y
for i in ${@:2};do
echo -e "\e[32;5m>>> $i\e[0m";
ssh-copy-id -f -i /etc/ceph/ceph.pub root@$i;
done
for i in ${@:2};do
echo -e "\e[32;5m>>> $i\e[0m";
ceph orch host add $i;
done
ceph orch apply osd --all-available-devices
eof
[root@ceph1 ~]# bash ceph-v15.2.17.sh ceph1 ceph2 ceph3 ceph4 ceph5
ceph orch host ls
ceph orch device ls
查看登录地址、用户、密码
grep -E 'URL|User|Password' ceph-init.log
egrep 'URL|User|Password' ceph-init.log
[root@ceph1~]# grep -E 'URL|User|Password' ceph-init.log
URL: https://ceph1:8443/
User: admin
Password: 3fhtw0j1az
[root@ceph1~]#