#ceph架构
#ceph支持的三种接口:
1 Object:有原生的API,而且也兼容Swift和S3的API。
2 Block:支持精简配置、快照、克隆。
3 File:Posix接口,支持快照。
Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-65-generic x86_64)
#ceph
nautilus 14.2.10-0.el7
#网络设计
192.168.3.0/24 #Cluster Network
192.168.1.0/24 #Public Network
#每台ceph节点下除系统盘外,挂2块硬盘
ceph009 eno3:192.168.3.9 eno5:192.168.1.9
ceph010 eno3:192.168.3.10 eno5:192.168.1.10
ceph011 eno3:192.168.3.11 eno5:192.168.1.11
#关闭防火墙
sudo ufw status
sudo ufw disable
#关闭selinux,最小化安装是没有selinux
hostnamectl set-hostname ceph009
su -
#vim /etc/hosts
#[ceph16]
192.168.1.9 ceph009
192.168.1.10 ceph010
192.168.1.11 ceph011
#系统源更换成ustc源,并更新文件缓存
wget -q -O- 'http://mirrors.ustc.edu.cn/ceph/keys/release.asc' | sudo apt-key add -
echo deb http://mirrors.ustc.edu.cn/ceph/debian-pacific/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
apt-get update
#个人比较喜欢用以下方式来同步时间
#修改时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate ntp3.aliyun.com
echo "*/3 * * * * ntpdate ntp3.aliyun.com &> /dev/null" > /tmp/crontab
crontab /tmp/crontab
##3# 1.3.7(可选)安装基础软件
apt install net-tools wget vim bash-completion lrzsz unzip zip ntpdate -y
#如果是在16版本,支持使用cephadm工具部署,ceph-deploy在14版本前都支持
#Ceph-deploy必须作为具有无密码sudo特权的用户登录到Ceph节点,因为它需要在不提示密码的情况下安装软件和配置文件
#启用没有密码的ssh,在ceph009执行即可,三次回车!
root@ceph009:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:cLdsgNQ2JFQFsFATaw/M6G8Sbs0voGJAsdybeUbg+ek root@ceph009
The key's randomart image is:
+---[RSA 3072]----+
| .oO*+o. |
| . . * *+ |
|. = + X.o.. |
| + = o = + . |
|. O . S + |
|. =.X . |
|. .B.= |
|.... E.. |
|.. .. |
+----[SHA256]-----+
#将密钥复制到每个Ceph节点
ssh-copy-id -o StrictHostKeyChecking=no root@ceph009
ssh-copy-id -o StrictHostKeyChecking=no root@ceph010
ssh-copy-id -o StrictHostKeyChecking=no root@ceph011
#验证,不需要输入密码即为成功
ssh root@ceph010
#创建集群目录,用于维护ceph-deploy为集群生成的配置文件和密钥。
mkdir ~/cephcluster && cd ~/cephcluster
root@ceph009:~/cephcluster# pwd
/root/cephcluster
#注意点
#ceph-deploy会将文件输出到当前目录。如果在执行ceph-deploy时,一定要确保您在这个目录中。
#附:节点清理
#如果在任何时候你遇到麻烦,你想重新开始,执行以下清除Ceph包,并擦除其所有数据和配置:
ceph-deploy forgetkeys
ceph-deploy purge ceph009 ceph010 ceph011
ceph-deploy purgedata ceph009 ceph010 ceph011
rm ceph.*
#安装ceph-deploy
apt-get install python3 python3-pip -y
#二选一,第一个国内加速下载地址,第二个为原地址慢
git clone https://github.com.cnpmjs.org/ceph/ceph-deploy.git
git clone https://github.com/ceph/ceph-deploy.git
cd ceph-deploy
#如果要使用ceph-deploy直接部署ceph那么需要修改以下这个文件
#vim /root/cephcluster/ceph-deploy/build/lib/ceph_deploy/install.py
#将args.release = 'nautilus' 修改成 args.release = 'pacific'
pip3 install setuptools
python3 setup.py install
#在cephcluster目录下执行创建集群
root@ceph009:~/cephcluster# ceph-deploy new ceph009 ceph010 ceph011
[ceph_deploy.conf][DEBUG ] found configuration file at: /root/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.1.0): /usr/local/bin/ceph-deploy new ceph009 ceph010 ceph011
[ceph_deploy.cli][