使用ceph-deploy部署ceph集群

一、ceph集群架构

二、准备工作

2.1 配置时钟同步

root@ceph-deploy:~# crontab -e
# 添加
*/5 * * * * /usr/sbin/ntpdate  time1.aliyun.com  &> /dev/null &&  hwclock  -w &> /dev/null

root@ceph-deploy:~# cat /etc/hosts
# 添加
# 阿里云ntp服务器
120.25.115.20    ntpdate ntp1.aliyun.com

2.2 准备镜像仓库

    涉及所有10台服务器

root@ceph-deploy:~# cat /etc/hosts
# 添加
183.204.196.229 mirrors.aliyun.com

root@ceph-deploy:~# cat /etc/apt/sources.list
# 配置阿里云镜像源头
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

root@ceph-deploy:~# apt update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]
Get:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages [2,249 kB]                                                                                                                          
Get:7 http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 Packages [1,360 kB]                                                                                                                           
Fetched 4,103 kB in 15s (275 kB/s)                                                                                                                                                                            
Reading package lists... Done
Building dependency tree       
Reading state information... Done
159 packages can be upgraded. Run 'apt list --upgradable' to see them.

2.3 创建ceph用户,并配置sudo免密

    涉及10台服务器

root@ceph-deploy:~# groupadd -r -g 2022 ceph && useradd -r -m -s /bin/bash -u 2022 -g 2022 ceph && echo ceph:123456 | chpasswd

root@ceph-deploy:~# echo "ceph    ALL=(ALL)    NOPASSWD:ALL" >> /etc/sudoers

2.4 在deploy节点配置免密登陆

    2.4.1 在deploy节点操作

root@ceph-deploy:~# su - ceph
ceph@ceph-deploy:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ceph/.ssh/id_rsa):
Created directory '/home/ceph/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ceph/.ssh/id_rsa.
Your public key has been saved in /home/ceph/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:akbiDJMo4dk15ClvMeAQJ2MsX1f+t0+VvNA3ty/e5ks [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|.*.o . ..        |
|o.* = o.         |
|o. + O  .        |
|.o+.+ +  .    o .|
|oo+..o. S . .. =+|
|.  =.o .   . ...*|
|    o +     . .E |
|     o       oo.o|
|             .o==|
+----[SHA256]——+

    2.4.2 将秘钥拷贝到其他服务器上

ceph@ceph-deploy:~$ ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ceph/.ssh/id_rsa.pub"
The authenticity of host '192.168.2.20 (192.168.2.20)' can't be established.
ECDSA key fingerprint is SHA256:9kHyC5k68pyboHx6VtTk2Id+y5UEBN3P0ZyM0srTZBc.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

其他服务器也执行如下操作
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]
   ssh-copy-id [email protected]

2.5 配置主机名解析

    涉及10台服务器

root@ceph-deploy:~# cat /etc/hosts
# 添加
101.6.15.130    mirrors.tuna.tsinghua.edu.cn
183.204.196.229 mirrors.aliyun.com
# 阿里云ntp服务器
120.25.115.20    ntpdate ntp1.aliyun.com


192.168.2.20    ceph-node1.example.local ceph-node1
192.168.2.21    ceph-node2.example.local ceph-node2
192.168.2.22    ceph-node3.example.local ceph-node3
192.168.2.23    ceph-node4.example.local ceph-node4
192.168.2.24    ceph-mgr1.example.local ceph-mgr1
192.168.2.25    ceph-mgr2.example.local ceph-mgr2
192.168.2.26    ceph-mon1.example.local ceph-mon1
192.168.2.27    ceph-mon2.example.local ceph-mon2
192.168.2.28    ceph-mon3.example.local ceph-mon3
192.168.2.29   ceph-deploy.example.local ceph-deploy

你可能感兴趣的:(k8s,ceph)