3 Ubuntu 部署 Ceph V16.2.5 PACIFIC3.1 部署方式3.2 实验服务器准备3.3 系统环境准备3.4 ceph-deploy 部署 RADOS 集群3.4.1 所有服务器同步时间3.4.2 配置清华源3.4.3 创建 ceph 用户3.4.4 各服务器允许 ceph 用户以 sudo 执行特权命令:3.4.5 配置免秘钥登录:3.4.6 配置主机名解析和修改主机名:3.4.7 安装 ceph 部署工具3.4.8 初始化 mon 节点3.4.9 初始化 ceph 集群3.4.10 mon 节点安装 ceph-mon 工具3.4.11 安装 mon 节点3.4.12 验证 mon 节点3.4.13 分发 admin 私钥3.4.14 ceph 节点验证密钥3.4.15 部署 ceph-mgr 节点3.4.16 ceph-deploy 创建 ceph-mgr 节点3.4.17 mgr 节点验证 mgr 服务是否启动3.4.18 初始化 node 节点3.4.19 去除 ceph 警告3.4.20 准备 OSD 节点3.4.21 添加 OSD 3.4.21 测试 ceph 集群数据上传和下载
3 Ubuntu 部署 Ceph V16.2.5 PACIFIC
http://docs.ceph.org.cn/install/manual-deployment/ #简要部署过程
https://docs.ceph.com/en/latest/releases/index.html
https://docs.ceph.com/en/latest/releases/octopus/ #ceph 15 即 octopus 版本支持的系统:
https://docs.ceph.com/en/latest/releases/pacific/ #ceph 16 即 Pacific 版本支持的系统:
在 ceph 16 中不在支持 centos7
3.1 部署方式
-
ceph-ansible:https://github.com/ceph/ceph-ansible #python
-
ceph-salt:https://github.com/ceph/ceph-salt #python
-
ceph-container:https://github.com/ceph/ceph-container #shell
-
ceph-chef:https://github.com/ceph/ceph-chef #Ruby
-
cephadm: https://docs.ceph.com/en/latest/cephadm/ #ceph 官方在 ceph 15 版本加入的 ceph 部署工具
-
ceph-deploy:https://github.com/ceph/ceph-deploy #python
-
是一个 ceph 官方维护的基于 ceph-deploy 命令行部署 ceph 集群的工具,基于 ssh 执行可以 sudo 权限的 shell 命令以及一些 python 脚本 实现 ceph 集群的部署和管理维护
-
Ceph-deploy 只用于部署和管理 ceph 集群,客户端需要访问 ceph,需要部署客户端工具。
3.2 实验服务器准备
-
网卡:每台服务器最少两块网卡,在生产中最好使用万兆网卡,(网卡 1 是走业务网络给客户端访问用来访问Ceph块存储文件存储或者对象存储,网卡 2 是存储网络让 ceph 集群中各个服务器来同步数据的)
-
四台服务器作为 ceph 集群 OSD 存储服务器,每台服务器三块或以上的磁盘,这里我添加的是每台服务器 5 块磁盘并且每块磁盘 100G
-
总结:我这里使用了 10 个节点,每个节点共计 10 块磁盘,两张网卡
1.网卡磁盘划分
网卡两块 | 磁盘 | CPU/内存 |
---|---|---|
eth0:10.0.0.100/16 (业务网卡) | /dev/sda ~ /dev/sde(共计5块,每块 100G) | 实验:2C / 2G |
eth1:192.168.10.0/16 (ceph 集群,并且这张网卡采用的是仅主机模式,在网卡配置文件中没有配置网关) | 生产: mon: 16c 16g mgr: 16c 16g |
2.一个服务器用于部署 ceph 集群即安装 Ceph-deploy,也可以和 ceph-mgr 等复用。
# ceph-deploy 节点
eth0:10.0.0.101 eth1:192.168.10.1
3.三台服务器作为 ceph 集群 Mon 监视服务器,每台服务器可以和 ceph 集群的 cluster 网络通信。
# ceph-mon1 节点
eth0:10.0.0.102 eth1:192.168.10.2
# ceph-mon2 节点
eth0:10.0.0.103 eth1:192.168.10.3
# ceph-mon3 节点
eth0:10.0.0.104 eth1:192.168.10.4
4.两个 ceph-mgr 管理服务器,可以和 ceph 集群的 cluster 网络通信
# ceph-mgr1 节点
eth0:10.0.0.105 eth1:192.168.10.5
# ceph-mgr2节点
eth0:10.0.0.106 eth1:192.168.10.6
5.四台服务器作为 ceph 集群 OSD 存储服务器,每台服务器支持两个网络,public 网络针对客户端访问,cluster 网络用于集群管理及数据同步,每台三块或以上的磁盘
# ceph-node1 节点 osd 存储服务器
eth0:10.0.0.107 eth1:192.168.10.7
# ceph-node2 节点 osd 存储服务器
eth0:10.0.0.108 eth1:192.168.10.8
# ceph-node3 节点 osd 存储服务器
eth0:10.0.0.109 eth1:192.168.10.9
# ceph-node4 节点 osd 存储服务器
eth0:10.0.0.110 eth1:192.168.10.10
6.创建一个普通用户,能够通过 sudo 执行特权命令,配置主机名解析,ceph 集群部署过程中需要对各主机配置不通的主机名,另外如果是 centos 系统则需要关闭各服务器的防火墙和 selinux。
实际结构如上图,cluster 网络是做 Ceph 集群中的数据同步和管理,一个 public 公开网络是给应用程序访问的,每个服务器两块网卡,如果是存储服务器的话磁盘还得高一点,在生产环境中除了磁盘还有网卡相关的配置都必须得跟得上
3.3 系统环境准备
-
时间同步 (ceph 要求时间同步相对较高)
-
关闭 selinux 和防火墙
-
配置域名解析或通过 DNS 解析
3.4 ceph-deploy 部署 RADOS 集群
默认情况下 ceph 的源在国外,所以我们这里采用的是国内的源
https://mirrors.aliyun.com/ceph/ #阿里云镜像仓库
http://mirrors.163.com/ceph/ #网易镜像仓库
https://mirrors.tuna.tsinghua.edu.cn/ceph/ #清华大学镜像源
注意:
我在下面操作中明确注释了什么阶段在 ceph 集群的所有节点上操作,在下面笔记中我简化了操作但是我有加黑字体提示
3.4.1 所有服务器同步时间
在 ceph 集群所有节点操作
# 这里同步阿里云时间
root@1:~# ntpdate time1.aliyun.com
3.4.2 配置清华源
在 ceph 集群所有节点操作
https://mirrors.tuna.tsinghua.edu.cn/help/ceph/
# 导入 ceph key
root@1:~# wget -q -O- https://mirrors.tuna.tsinghua.edu.cn/ceph/keys/release.asc | sudo apt-key add -
# 配置清华的 ceph 源
root@1:~# sudo echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-pacific/ bionic main' >> /etc/apt/sources.list
# 更新镜像源
root@1:~# sudo apt update
3.4.3 创建 ceph 用户
在 ceph 集群所有节点操作
推荐使用指定的普通用户部署和运行 ceph 集群,普通用户只要能以非交互方式执行 sudo 命令执行一些特权命令即可,新版的 ceph-deploy 可以指定包含 root 的在内只要可以执行 sudo 命令的用户,不过仍然推荐使用普通用户,比如 ceph、cephuser、cephadmin 这样的用户去管理 ceph 集群
在包含 ceph-deploy 节点的存储节点、mon 节点和 mgr 节点等创建 ceph 用户。
# 创建 ceph 用户
root@1:~# groupadd -r -g 2022 ceph && useradd -r -m -s /bin/bash -u 2022 -g 2022 ceph && echo ceph:123456 | chpasswd
# 查看 id 2022 是否为 ceph
root@1:~# id 2022
uid=2022(ceph) gid=2022(ceph) groups=2022(ceph)
3.4.4 各服务器允许 ceph 用户以 sudo 执行特权命令:
在 ceph 集群所有节点操作
root@1:~# echo "ceph ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
3.4.5 配置免秘钥登录:
在 node1 (ceph-deploy)节点操作
在 ceph-deploy 节点配置允许以非交互的方式登录到各 ceph node/mon/mgr 节点,即在 ceph-deploy 节点生成秘钥对,然后分发公钥到各被管理节点:
主要实现 ceph-deploy 的公钥拷贝到被管理的节点
# 在 node1 上操作
# 切换至 ceph 用户
root@1:~# su - ceph
# 生成 ceph 的公钥
ceph@1:~$ 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:1eVyJ1SaS+k/IR/vLHRV3fdn5U/1DuZS9I+/8k4yn9U ceph@1
The key's randomart image is:
+---[RSA 2048]----+
| o.+|
| . +.+B|
| . o.OoO|
| . =++X|
| S =oO=|
| . *.X|
| = *E|
| .*o=|
| +B+|
+----[SHA256]-----+
# 拷贝给 ceph-deploy 也就是本机 node-1 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.101
# 拷贝给 mon1 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.102
# 拷贝给 mon2 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.103
# 拷贝给 mon3 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.104
# 拷贝给 mgr1 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.105
# 拷贝给 mgr2 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.106
# 拷贝给 node1 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.107
# 拷贝给 node2 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.108
# 拷贝给 node3 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.109
# 拷贝给 node4 节点
ceph@1:~$ ssh-copy-id ceph@10.0.0.110
3.4.6 配置主机名解析和修改主机名:
ceph 集群中的 node1 节点上操作
这里面的 ip 是使用的我们的业务 ip ,而非 ceph 集群内部使用 ip
# 切换到 root 用户
ceph@1:~$ su
Password:
# 编辑主机头文件
root@1:/home/ceph# vim /etc/hosts
127.0.0.1 localhost
127.0.1.1 init.localdomain init
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.0.101 ceph-deploy.example.local ceph-deploy
10.0.0.102 ceph-mon1.example.local ceph-mon1
10.0.0.103 ceph-mon2.example.local ceph-mon2
10.0.0.104 ceph-mon3.example.local ceph-mon3
10.0.0.105 ceph-mgr1.example.local ceph-mgr1
10.0.0.106 ceph-mgr2.example.local ceph-mgr2
10.0.0.107 ceph-node1.example.local ceph-node1
10.0.0.108 ceph-node2.example.local ceph-node2
10.0.0.109 ceph-node3.example.local ceph-node3
10.0.0.110 ceph-node4.example.local ceph-node4
# 拷贝给 mon1 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.102:/etc/hosts
# 拷贝给 mon2 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.103:/etc/hosts
# 拷贝给 mon3 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.104:/etc/hosts
# 拷贝给 mrg1 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.105:/etc/hosts
# 拷贝给 mrg2 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.106:/etc/hosts
# 拷贝给 node1 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.107:/etc/hosts
# 拷贝给 node2 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.108:/etc/hosts
# 拷贝给 node3 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.109:/etc/hosts
# 拷贝给 node4 节点
root@1:/home/ceph# scp /etc/hosts 10.0.0.110:/etc/hosts
接着修改主机名
# 因为我们在 /etc/hosts 中使用的是下面的主机名,所以等会 ceph 安装的时候会解析对应的主机名
root@1:~# hostnamectl set-hostname ceph-deploy
root@2:~# hostnamectl set-hostname ceph-mon1
root@3:~# hostnamectl set-hostname ceph-mon2
root@4:~# hostnamectl set-hostname ceph-mon3
root@5:~# hostnamectl set-hostname ceph-mgr1
root@6:~# hostnamectl set-hostname ceph-mgr2
root@7:~# hostnamectl set-hostname ceph-node1
root@8:~# hostnamectl set-hostname ceph-node2
root@9:~# hostnamectl set-hostname ceph-node3
root@10:~# hostnamectl set-hostname ceph-node4
3.4.7 安装 ceph 部署工具
在 ceph 部署服务器安装部署工具 ceph-deploy ,ceph 集群中的 ceph-deploy 节点上操作
# 通过 apt-cache 查看 ceph-deploy 包版本
root@1:~# apt-cache madison ceph-deploy
ceph-deploy | 2.0.1 | https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-octopus buster/main amd64 Packages
ceph-deploy | 2.0.1 | https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-octopus buster/main i386 Packages
ceph-deploy | 2.0.1 | https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-pacific bionic/main amd64 Packages
ceph-deploy | 2.0.1 | https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-pacific bionic/main i386 Packages
ceph-deploy | 1.5.38-0ubuntu1 | http://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages
ceph-deploy | 1.5.38-0ubuntu1 | http://mirrors.aliyun.com/ubuntu bionic/universe i386 Packages
ceph-deploy | 1.5.38-0ubuntu1 | http://mirrors.aliyun.com/ubuntu bionic/universe Sources
# 安装 ceph-deploy ,然后通过该工具来部署 ceph 环境
root@1:~# apt install ceph-deploy -y
3.4.8 初始化 mon 节点
1.在管理节点初始化 mon 节点 ,ceph 集群中的 ceph-deploy 节点上操作
# 切换至 ceph 用户
root@1:~# su - ceph
# 创建 ceph-cluster 目录,保存当前集群的初始化配置信息
ceph@1:~$ mkdir ceph-cluster
# 进入 ceph-cluster
ceph@1:~$ cd ceph-cluster/
# 查看 ceph-deploy 帮助
ceph@1:~/ceph-cluster$ ceph-deploy --help
new:开始部署一个新的 ceph 存储集群,并生成 CLUSTER.conf 集群配置文件和 keyring 认证文件。
install: 在远程主机上安装 ceph 相关的软件包, 可以通过--release 指定安装的版本。
rgw:管理 RGW 守护程序(RADOSGW,对象存储网关)。
mgr:管理 MGR 守护程序(ceph-mgr,Ceph Manager DaemonCeph 管理器守护程序)。
mds:管理 MDS 守护程序(Ceph Metadata Server,ceph 源数据服务器)。
mon:管理 MON 守护程序(ceph-mon,ceph 监视器)。
gatherkeys:从指定获取提供新节点的验证 keys,这些 keys 会在添加新的 MON/OSD/MD 加入的时候使用。
disk:管理远程主机磁盘。
osd:在远程主机准备数据磁盘,即将指定远程主机的指定磁盘添加到 ceph 集群作为 osd 使用。
repo: 远程主机仓库管理。
admin:推送 ceph 集群配置文件和 client.admin 认证文件到远程主机。
config:将 ceph.conf 配置文件推送到远程主机或从远程主机拷贝。
uninstall:从远端主机删除安装包。
purgedata:从/var/lib/ceph 删除 ceph 数据,会删除/etc/ceph 下的内容。
purge: 删除远端主机的安装包和所有数据。
forgetkeys:从本地主机删除所有的验证 keyring, 包括 client.admin, monitor, bootstrap 等 认证文件。
pkg: 管理远端主机的安装包。
calamari:安装并配置一个 calamari web 节点,calamari 是一个 web 监控平台。
# 切换为 root ,因为下面操作需要在 root 用户操作
ceph@1:~/ceph-cluster$ su -
Password:
2.初始化 mon 节点过程如下: 在所有的 ceph 节点操作
# Ubuntu 各服务器需要单独安装 Python2 ,因为 ceph-deploy 是通过 py 写的所有需要环境
root@1:~# apt install python2.7 -y
# 软链接,如果不软连接就会报错,因为 ceph-deploy 需要用到 python2
root@1:~# ln -sv /usr/bin/python2.7 /usr/bin/python2
3.4.9 初始化 ceph 集群
在 ceph-deploy 节点上操作,
# 切换到 ceph 用户,并进入 ceph-cluster 目录
root@1:~# su - ceph
ceph@1:~$ cd ceph-cluster/
[ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy new --cluster-network 192.168.10.0/24 --public-network 10.0.0.0/24 ceph-mon1.example.local
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7f43368e9dc0>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] ssh_copykey : True
[ceph_deploy.cli][INFO ] mon : ['ceph-mon1.example.local']
[ceph_deploy.cli][INFO ] func : <function new at 0x7f4333b9dad0>
[ceph_deploy.cli][INFO ] public_network : 10.0.0.0/24
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] cluster_network : 192.168.10.0/24
[ceph_deploy.cli][INFO ] default_release : False
[ceph_deploy.cli][INFO ] fsid : None
[ceph_deploy.new][DEBUG ] Creating new cluster named ceph
[ceph_deploy.new][INFO ] making sure passwordless SSH succeeds
[ceph-mon1.example.local][DEBUG ] connected to host: 1
[ceph-mon1.example.local][INFO ] Running command: ssh -CT -o BatchMode=yes ceph-mon1.example.local
[ceph_deploy.new][WARNIN] could not connect via SSH
[ceph_deploy.new][INFO ] will connect again with password prompt
The authenticity of host 'ceph-mon1.example.local (10.0.0.102)' can't be established.
ECDSA key fingerprint is SHA256:xtqzLytgnfFCqMji/jMFDE6omSUPAra+MC44v1Lie1c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ceph-mon1.example.local' (ECDSA) to the list of known hosts.
[ceph-mon1.example.local][DEBUG ] connected to host: ceph-mon1.example.local
[ceph-mon1.example.local][DEBUG ] detect platform information from remote host
[ceph-mon1.example.local][DEBUG ] detect machine type
[ceph_deploy.new][INFO ] adding public keys to authorized_keys
[ceph-mon1.example.local][DEBUG ] append contents to file
[ceph-mon1.example.local][DEBUG ] connection detected need for sudo
[ceph-mon1.example.local][DEBUG ] connected to host: ceph-mon1.example.local
[ceph-mon1.example.local][DEBUG ] detect platform information from remote host
[ceph-mon1.example.local][DEBUG ] detect machine type
[ceph-mon1.example.local][DEBUG ] find the location of an executable
[ceph-mon1.example.local][INFO ] Running command: sudo /bin/ip link show
[ceph-mon1.example.local][INFO ] Running command: sudo /bin/ip addr show
[ceph-mon1.example.local][DEBUG ] IP addresses found: [u'10.0.0.102', u'192.168.10.2']
[ceph_deploy.new][DEBUG ] Resolving host ceph-mon1.example.local
[ceph_deploy.new][DEBUG ] Monitor ceph-mon1 at 10.0.0.102
[ceph_deploy.new][DEBUG ] Monitor initial members are ['ceph-mon1']
[ceph_deploy.new][DEBUG ] Monitor addrs are [u'10.0.0.102']
[ceph_deploy.new][DEBUG ] Creating a random mon key...
[ceph_deploy.new][DEBUG ] Writing monitor keyring to ceph.mon.keyring...
[ceph_deploy.new][DEBUG ] Writing initial config to ceph.conf...
# 主要是生成下面几个文件
ceph@1:~/ceph-cluster$ ll
total 16
-rw-rw-r-- 1 ceph ceph 263 Oct 21 14:24 ceph.conf #自动生成的配置文件
-rw-rw-r-- 1 ceph ceph 7096 Oct 21 14:24 ceph-deploy-ceph.log #初始化日志
-rw------- 1 ceph ceph 73 Oct 21 14:24 ceph.mon.keyring #用于 ceph mon 节点内部通 讯认证的秘钥环文件
# ceph 配置文件内容如下
ceph@1:~/ceph-cluster$ cat ceph.conf
[global]
fsid = cf6d4955-4d0d-469d-a683-86001fe670ce # 集群id
public_network = 10.0.0.0/24 # 业务网络
cluster_network = 192.168.10.0/24 # ceph 集群内部网络
mon_initial_members = ceph-mon1 # mon 初始 members 现在只初始化了一个节点
mon_host = 10.0.0.102 # mon 节点地址
auth_cluster_required = cephx # 认证协议走的 cephx
auth_service_required = cephx
auth_client_required = cephx
# 现在只是生成了 mon 的配置文件,并没有对 mon 安装工具的操作
3.4.10 mon 节点安装 ceph-mon 工具
在 3 个 mon 节点上安装
# mon1 节点安装
root@2:~# apt install ceph-mon -y
# mon2 节点安装
root@3:~# apt install ceph-mon -y
# mon3 节点安装
root@4:~# apt install ceph-mon -y
直接回车
回车
3.4.11 安装 mon 节点
在 ceph-deploy 节点上操作
# 切换为 ceph 用户
root@ceph-deploy:~# su - ceph
ceph@ceph-deploy:~$ cd ceph-cluster/
# 执行安装 mon 节点
ceph@ceph-deploy:~/ceph-cluster$ ceph-deploy mon create-initial
[ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy mon create-initial
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] subcommand : create-initial
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fd672c82fa0>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] func : <function mon at 0x7fd672c65ad0>
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] keyrings : None
[ceph_deploy.cli][INFO ] default_release : False
[ceph_deploy.mon][DEBUG ] Deploying mon, cluster ceph hosts ceph-mon1
[ceph_deploy.mon][DEBUG ] detecting platform for host ceph-mon1 ...
ceph@ceph-mon1's password:
[ceph-mon1][DEBUG ] connection detected need for sudo
ceph@ceph-mon1's password:
[ceph-mon1][DEBUG ] connected to host: ceph-mon1
[ceph-mon1][DEBUG ] detect platform information from remote host
[ceph-mon1][DEBUG ] detect machine type
[ceph-mon1][DEBUG ] find the location of an executable
[ceph_deploy.mon][INFO ] distro info: Ubuntu 18.04 bionic
[ceph-mon1][DEBUG ] determining if provided host has same hostname in remote
[ceph-mon1][DEBUG ] get remote short hostname
[ceph-mon1][DEBUG ] deploying mon to ceph-mon1
[ceph-mon1][DEBUG ] get remote short hostname
[ceph-mon1][DEBUG ] remote hostname: ceph-mon1
[ceph-mon1][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf
[ceph-mon1][DEBUG ] create the mon path if it does not exist
[ceph-mon1][DEBUG ] checking for done path: /var/lib/ceph/mon/ceph-ceph-mon1/done
[ceph-mon1][DEBUG ] done path does not exist: /var/lib/ceph/mon/ceph-ceph-mon1/done
[ceph-mon1][INFO ] creating keyring file: /var/lib/ceph/tmp/ceph-ceph-mon1.mon.keyring
[ceph-mon1][DEBUG ] create the monitor keyring file
[ceph-mon1][INFO ] Running command: sudo ceph-mon --cluster ceph --mkfs -i ceph-mon1 --keyring /var/lib/ceph/tmp/ceph-ceph-mon1.mon.keyring --setuser 2022 --setgroup 2022
[ceph-mon1][INFO ] unlinking keyring file /var/lib/ceph/tmp/ceph-ceph-mon1.mon.keyring
[ceph-mon1][DEBUG ] create a done file to avoid re-doing the mon deployment
[ceph-mon1][DEBUG ] create the init path if it does not exist
[ceph-mon1][INFO ] Running command: sudo systemctl enable ceph.target
[ceph-mon1][INFO ] Running command: sudo systemctl enable ceph-mon@ceph-mon1
[ceph-mon1][INFO ] Running command: sudo systemctl start ceph-mon@ceph-mon1
[ceph-mon1][WARNIN] No data was received after 7 seconds, disconnecting...
[ceph-mon1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.ceph-mon1.asok mon_status
[ceph-mon1][DEBUG ] ********************************************************************************
[ceph-mon1][DEBUG ] status for monitor: mon.ceph-mon1
[ceph-mon1][DEBUG ] {
[ceph-mon1][DEBUG ] "election_epoch": 3,
[ceph-mon1][DEBUG ] "extra_probe_peers": [],
[ceph-mon1][DEBUG ] "feature_map": {
[ceph-mon1][DEBUG ] "mon": [
[ceph-mon1][DEBUG ] {
[ceph-mon1][DEBUG ] "features": "0x3f01cfb9fffdffff",
[ceph-mon1][DEBUG ] "num": 1,
[ceph-mon1][DEBUG ] "release": "luminous"
[ceph-mon1][DEBUG ] }
[ceph-mon1][DEBUG ] ]
[ceph-mon1][DEBUG ] },
[ceph-mon1][DEBUG ] "features": {
[ceph-mon1][DEBUG ] "quorum_con": "4540138297136906239",
[ceph-mon1][DEBUG ] "quorum_mon": [
[ceph-mon1][DEBUG ] "kraken",
[ceph-mon1][DEBUG ] "luminous",
[ceph-mon1][DEBUG ] "mimic",
[ceph-mon1][DEBUG ] "osdmap-prune",
[ceph-mon1][DEBUG ] "nautilus",
[ceph-mon1][DEBUG ] "octopus",
[ceph-mon1][DEBUG ] "pacific",
[ceph-mon1][DEBUG ] "elector-pinging"
[ceph-mon1][DEBUG ] ],
[ceph-mon1][DEBUG ] "required_con": "2449958747317026820",
[ceph-mon1][DEBUG ] "required_mon": [
[ceph-mon1][DEBUG ] "kraken",
[ceph-mon1][DEBUG ] "luminous",
[ceph-mon1][DEBUG ] "mimic",
[ceph-mon1][DEBUG ] "osdmap-prune",
[ceph-mon1][DEBUG ] "nautilus",
[ceph-mon1][DEBUG ] "octopus",
[ceph-mon1][DEBUG ] "pacific",
[ceph-mon1][DEBUG ] "elector-pinging"
[ceph-mon1][DEBUG ] ]
[ceph-mon1][DEBUG ] },
[ceph-mon1][DEBUG ] "monmap": {
[ceph-mon1][DEBUG ] "created": "2021-08-20T10:32:22.783403Z",
[ceph-mon1][DEBUG ] "disallowed_leaders: ": "",
[ceph-mon1][DEBUG ] "election_strategy": 1,
[ceph-mon1][DEBUG ] "epoch": 1,
[ceph-mon1][DEBUG ] "features": {
[ceph-mon1][DEBUG ] "optional": [],
[ceph-mon1][DEBUG ] "persistent": [
[ceph-mon1][DEBUG ] "kraken",
[ceph-mon1][DEBUG ] "luminous",
[ceph-mon1][DEBUG ] "mimic",
[ceph-mon1][DEBUG ] "osdmap-prune",
[ceph-mon1][DEBUG ] "nautilus",
[ceph-mon1][DEBUG ] "octopus",
[ceph-mon1][DEBUG ] "pacific",
[ceph-mon1][DEBUG ] "elector-pinging"
[ceph-mon1][DEBUG ] ]
[ceph-mon1][DEBUG ] },
[ceph-mon1][DEBUG ] "fsid": "14ce1d1a-3323-4337-963a-f96484ddd363",
[ceph-mon1][DEBUG ] "min_mon_release": 16,
[ceph-mon1][DEBUG ] "min_mon_release_name": "pacific",
[ceph-mon1][DEBUG ] "modified": "2021-08-20T10:32:22.783403Z",
[ceph-mon1][DEBUG ] "mons": [
[ceph-mon1][DEBUG ] {
[ceph-mon1][DEBUG ] "addr": "10.0.0.102:6789/0",
[ceph-mon1][DEBUG ] "crush_location": "{}",
[ceph-mon1][DEBUG ] "name": "ceph-mon1",
[ceph-mon1][DEBUG ] "priority": 0,
[ceph-mon1][DEBUG ] "public_addr": "10.0.0.102:6789/0",
[ceph-mon1][DEBUG ] "public_addrs": {
[ceph-mon1][DEBUG ] "addrvec": [
[ceph-mon1][DEBUG ] {
[ceph-mon1][DEBUG ] "addr": "10.0.0.102:3300",
[ceph-mon1][DEBUG ] "nonce": 0,
[ceph-mon1][DEBUG ] "type": "v2"
[ceph-mon1][DEBUG ] },
[ceph-mon1][DEBUG ] {
[ceph-mon1][DEBUG ] "addr": "10.0.0.102:6789",
[ceph-mon1][DEBUG ] "nonce": 0,
[ceph-mon1][DEBUG ] "type": "v1"
[ceph-mon1][DEBUG ] }
[ceph-mon1][DEBUG ] ]
[ceph-mon1][DEBUG ] },
[ceph-mon1][DEBUG ] "rank": 0,
[ceph-mon1][DEBUG ] "weight": 0
[ceph-mon1][DEBUG ] }
[ceph-mon1][DEBUG ] ],
[ceph-mon1][DEBUG ] "stretch_mode": false
[ceph-mon1][DEBUG ] },
[ceph-mon1][DEBUG ] "name": "ceph-mon1",
[ceph-mon1][DEBUG ] "outside_quorum": [],
[ceph-mon1][DEBUG ] "quorum": [
[ceph-mon1][DEBUG ] 0
[ceph-mon1][DEBUG ] ],
[ceph-mon1][DEBUG ] "quorum_age": 0,
[ceph-mon1][DEBUG ] "rank": 0,
[ceph-mon1][DEBUG ] "state": "leader",
[ceph-mon1][DEBUG ] "stretch_mode": false,
[ceph-mon1][DEBUG ] "sync_provider": []
[ceph-mon1][DEBUG ] }
[ceph-mon1][DEBUG ] ********************************************************************************
[ceph-mon1][INFO ] monitor: mon.ceph-mon1 is running
[ceph-mon1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.ceph-mon1.asok mon_status
[ceph_deploy.mon][INFO ] processing monitor mon.ceph-mon1
ceph@ceph-mon1's password:
[ceph-mon1][DEBUG ] connection detected need for sudo
ceph@ceph-mon1's password:
[ceph-mon1][DEBUG ] connected to host: ceph-mon1
[ceph-mon1][DEBUG ] detect platform information from remote host
[ceph-mon1][DEBUG ] detect machine type
[ceph-mon1][DEBUG ] find the location of an executable
[ceph-mon1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.ceph-mon1.asok mon_status
[ceph_deploy.mon][INFO ] mon.ceph-mon1 monitor has reached quorum!
[ceph_deploy.mon][INFO ] all initial monitors are running and have formed quorum
[ceph_deploy.mon][INFO ] Running gatherkeys...
[ceph_deploy.gatherkeys][INFO ] Storing keys in temp directory /tmp/tmpAAqm94
ceph@ceph-mon1's password:
[ceph-mon1][DEBUG ] connection detected need for sudo
ceph@ceph-mon1's password:
[ceph-mon1][DEBUG ] connected to host: ceph-mon1
[ceph-mon1][DEBUG ] detect platform information from remote host
[ceph-mon1][DEBUG ] detect machine type
[ceph-mon1][DEBUG ] get remote short hostname
[ceph-mon1][DEBUG ] fetch remote file
[ceph-mon1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --admin-daemon=/var/run/ceph/ceph-mon.ceph-mon1.asok mon_status
[ceph-mon1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --namemon. --keyring=/var/lib/ceph/mon/ceph-ceph-mon1/keyring auth get client.admin
[ceph-mon1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --namemon. --keyring=/var/lib/ceph/mon/ceph-ceph-mon1/keyring auth get client.bootstrap-mds
[ceph-mon1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --namemon. --keyring=/var/lib/ceph/mon/ceph-ceph-mon1/keyring auth get client.bootstrap-mgr
[ceph-mon1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --namemon. --keyring=/var/lib/ceph/mon/ceph-ceph-mon1/keyring auth get client.bootstrap-osd
[ceph-mon1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --namemon. --keyring=/var/lib/ceph/mon/ceph-ceph-mon1/keyring auth get client.bootstrap-rgw
[ceph_deploy.gatherkeys][INFO ] Storing ceph.client.admin.keyring
[ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-mds.keyring
[ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-mgr.keyring
[ceph_deploy.gatherkeys][INFO ] keyring 'ceph.mon.keyring' already exists
[ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-osd.keyring
[ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-rgw.keyring
[ceph_deploy.gatherkeys][INFO ] Destroy temp directory /tmp/tmpAAqm94
3.4.12 验证 mon 节点
在 mon1 节点操作
验证在 mon 定节点已经自动安装并启动了 ceph-mon 服务,并且后期在 ceph-deploy 节点初始化目录会生成一些 bootstrap ceph mds/mgr/osd/rgw 等服务的 keyring 认证文件,这些初始化文件拥有对 ceph 集群的最高权限,所以一定要保存好。
# 验证 mon 进程已经启动,并且会加载 ceph-mo1 主机名解析,通过 ceph 用户启动
root@ceph-mon1:/var/run/ceph# ps -ef | grep ceph-mon
ceph 17591 1 0 18:32 ? 00:00:01 /usr/bin/ceph-mon -f --cluster ceph --id ceph-mo1 --setuser ceph --setgroup ceph
3.4.13 分发 admin 私钥
在 ceph-deploy 节点 安装 ceph-common 命令
在 ceph-deploy 节点把配置文件和 admin 密钥拷贝至 Ceph 集群需要执行 ceph 管理命令的节点,从而不需要后期通过 ceph 命令对 ceph 集群进行管理配置的时候每次都需要指定 ceph-mon 节点地址和 ceph.client.admin.keyring 文件,另外各 ceph-mon 节点也需要同步 ceph 的集群配置文件与认证文件。
# 通过 ssh 切换至 ceph 用户
ceph@ceph-deploy:~/ceph-cluster$ ssh root@10.0.0.101
# 安装 ceph-common 命令
root@ceph-deploy:~# apt install ceph-common -y
3.4.14 ceph 节点验证密钥
在所有安装了 ceph-common 工具的节点上为 ceph 用户添加权限
认证文件的属主和属组为了安全考虑,默认设置为了 root 用户和 root 组,如果需要 ceph 用户也能执行 ceph 命令,那么就需要对 ceph 用户进行授权,
[22:14:10 ceph@ceph-deploy ~]$ setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
root@ceph-node1:~# setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
root@ceph-node2:~# setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
root@ceph-node3:~# setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
root@ceph-node4:~# setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
3.4.15 部署 ceph-mgr 节点
在所有的 ceph-mgr 节点上操作
mgr 节点需要读取 ceph 的配置文件,即/etc/ceph 目录中的配置文件
root@ceph-mgr1:~# apt install ceph-mgr -y
root@ceph-mgr2:~# apt install ceph-mgr -y
3.4.16 ceph-deploy 创建 ceph-mgr 节点
ceph-deploy 节点操作
ceph-mgr 节点部署好了之后回到 ceph-deploy 节点开始创建 ceph-mgr
# 进入到 ceph-cluster 目录下创建,因为它会读取 ceph.conf 文件
[22:20:33 ceph@ceph-deploy ~]$cd /home/ceph/ceph-cluster/
# 多个 mgr 节点中间以空格隔开
[22:20:44 ceph@ceph-deploy ceph-cluster]$ceph-deploy mgr create ceph-mgr1 ceph-mgr2
[ceph_deploy.conf][DEBUG ] found configuration file at: /var/lib/ceph/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy mgr create ceph-mgr1 ceph-mgr2
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] mgr : [('ceph-mgr1', 'ceph-mgr1'), ('ceph-mgr2', 'ceph-mgr2')]
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] subcommand : create
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fbf16faabe0>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] func : <function mgr at 0x7fbf1740a150>
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] default_release : False
[ceph_deploy.mgr][DEBUG ] Deploying mgr, cluster ceph hosts ceph-mgr1:ceph-mgr1 ceph-mgr2:ceph-mgr2
The authenticity of host 'ceph-mgr1 (10.0.0.105)' can't be established.
ECDSA key fingerprint is SHA256:xtqzLytgnfFCqMji/jMFDE6omSUPAra+MC44v1Lie1c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ceph-mgr1,10.0.0.105' (ECDSA) to the list of known hosts.
ceph@ceph-mgr1's password:
[ceph-mgr1][DEBUG ] connection detected need for sudo
ceph@ceph-mgr1's password:
[ceph-mgr1][DEBUG ] connected to host: ceph-mgr1
[ceph-mgr1][DEBUG ] detect platform information from remote host
[ceph-mgr1][DEBUG ] detect machine type
[ceph_deploy.mgr][INFO ] Distro info: Ubuntu 18.04 bionic
[ceph_deploy.mgr][DEBUG ] remote host will use systemd
[ceph_deploy.mgr][DEBUG ] deploying mgr bootstrap to ceph-mgr1
[ceph-mgr1][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf
[ceph-mgr1][WARNIN] mgr keyring does not exist yet, creating one
[ceph-mgr1][DEBUG ] create a keyring file
[ceph-mgr1][DEBUG ] create path recursively if it doesn't exist
[ceph-mgr1][INFO ] Running command: sudo ceph --cluster ceph --name client.bootstrap-mgr --keyring /var/lib/ceph/bootstrap-mgr/ceph.keyring auth get-or-create mgr.ceph-mgr1 mon allow profile mgr osd allow * mds allow * -o /var/lib/ceph/mgr/ceph-ceph-mgr1/keyring
[ceph-mgr1][INFO ] Running command: sudo systemctl enable ceph-mgr@ceph-mgr1
[ceph-mgr1][WARNIN] Created symlink /etc/systemd/system/ceph-mgr.target.wants/ceph-mgr@ceph-mgr1.service → /lib/systemd/system/ceph-mgr@.service.
[ceph-mgr1][INFO ] Running command: sudo systemctl start ceph-mgr@ceph-mgr1
[ceph-mgr1][INFO ] Running command: sudo systemctl enable ceph.target
The authenticity of host 'ceph-mgr2 (10.0.0.106)' can't be established.
ECDSA key fingerprint is SHA256:xtqzLytgnfFCqMji/jMFDE6omSUPAra+MC44v1Lie1c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ceph-mgr2,10.0.0.106' (ECDSA) to the list of known hosts.
ceph@ceph-mgr2's password:
[ceph-mgr2][DEBUG ] connection detected need for sudo
ceph@ceph-mgr2's password:
[ceph-mgr2][DEBUG ] connected to host: ceph-mgr2
[ceph-mgr2][DEBUG ] detect platform information from remote host
[ceph-mgr2][DEBUG ] detect machine type
[ceph_deploy.mgr][INFO ] Distro info: Ubuntu 18.04 bionic
[ceph_deploy.mgr][DEBUG ] remote host will use systemd
[ceph_deploy.mgr][DEBUG ] deploying mgr bootstrap to ceph-mgr2
[ceph-mgr2][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf
[ceph-mgr2][WARNIN] mgr keyring does not exist yet, creating one
[ceph-mgr2][DEBUG ] create a keyring file
[ceph-mgr2][DEBUG ] create path recursively if it doesn't exist
[ceph-mgr2][INFO ] Running command: sudo ceph --cluster ceph --name client.bootstrap-mgr --keyring /var/lib/ceph/bootstrap-mgr/ceph.keyring auth get-or-create mgr.ceph-mgr2 mon allow profile mgr osd allow * mds allow * -o /var/lib/ceph/mgr/ceph-ceph-mgr2/keyring
[ceph-mgr2][INFO ] Running command: sudo systemctl enable ceph-mgr@ceph-mgr2
[ceph-mgr2][WARNIN] Created symlink /etc/systemd/system/ceph-mgr.target.wants/ceph-mgr@ceph-mgr2.service → /lib/systemd/system/ceph-mgr@.service.
[ceph-mgr2][INFO ] Running command: sudo systemctl start ceph-mgr@ceph-mgr2
[ceph-mgr2][INFO ] Running command: sudo systemctl enable ceph.target
3.4.17 mgr 节点验证 mgr 服务是否启动
ceph-mgr 节点操作
# 并且这个 mgr 服务会自动设置为开机自启
root@ceph-mgr1:~# ps -ef | grep mgr
ceph 9853 1 5 22:22 ? 00:00:05 /usr/bin/ceph-mgr -f --cluster ceph --id ceph-mgr1 --setuser ceph --setgroup ceph
root@ceph-mgr2:~# ps -ef | grep mgr
ceph 9853 1 5 22:22 ? 00:00:05 /usr/bin/ceph-mgr -f --cluster ceph --id ceph-mgr2 --setuser ceph --setgroup ceph
3.4.18 初始化 node 节点
ceph-deploy 节点上操作
其实在 node 节点装好了 ceph 之后我们需要使用到 ceph-volume 擦除磁盘添加 osd,如果磁盘擦除不了 osd 就添加不到 ceph 集群中
# 我们在装好了 ceph 集群之后还需要添加 node 节点,因为 OSD 存储服务是运行在 node 节点上
[22:30:11 ceph@ceph-deploy ceph-cluster]$ceph-deploy ceph-node1 ceph-node2 ceph-node3 ceph-node4
[ceph_deploy.conf][DEBUG ] found configuration file at: /var/lib/ceph/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy install --no-adjust-repos --nogpgcheck ceph-node1 ceph-node2 ceph-node3 ceph-node4
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] testing : None
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7f3d5ec6bbe0>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] dev_commit : None
[ceph_deploy.cli][INFO ] install_mds : False
................................. 省略 ......................
3.4.19 去除 ceph 警告
ceph-deploy 节点上操作
# 默认装好 ceph 之后会有告警
[22:22:14 ceph@ceph-deploy ceph-cluster]$ceph -s
cluster:
id: 14ce1d1a-3323-4337-963a-f96484ddd363
health: HEALTH_WARN
mon is allowing insecure global_id reclaim # 告警mon允许不安全的全局\u id回收
OSD count 0 < osd_pool_default_size 3 # OSD 总数为 0 默认大小为 3 个
services:
mon: 1 daemons, quorum ceph-mon1 (age 3h)
mgr: ceph-mgr1(active, since 22s), standbys: ceph-mgr2
osd: 0 osds: 0 up, 0 in
data:
pools: 0 pools, 0 pgs
objects: 0 objects, 0 B
usage: 0 B used, 0 B / 0 B avail
pgs:
# 通过下面命令去除告警,其实就是通过给 mon 节点修改配置 auth_allow_insecure_global_id_reclaim 将该值改为 false 禁止非安全的 id 回收
[22:41:50 ceph@ceph-deploy ceph-cluster]$ceph config set mon auth_allow_insecure_global_id_reclaim false
# 我们现在观察就没有 mon is allowing insecure global_id reclaim 告警
[22:42:21 ceph@ceph-deploy ceph-cluster]$ceph -s
cluster:
id: 14ce1d1a-3323-4337-963a-f96484ddd363
health: HEALTH_WARN
OSD count 0 < osd_pool_default_size 3
services:
mon: 1 daemons, quorum ceph-mon1 (age 3h)
mgr: ceph-mgr1(active, since 20m), standbys: ceph-mgr2
osd: 0 osds: 0 up, 0 in
data:
pools: 0 pools, 0 pgs
objects: 0 objects, 0 B
usage: 0 B used, 0 B / 0 B avail
pgs:
3.4.20 准备 OSD 节点
ceph-deploy 节点上操作
# 列出 ceph-noed1 节点的磁盘信息
[22:42:30 ceph@ceph-deploy ceph-cluster]$ceph-deploy disk list ceph-node1
[ceph_deploy.conf][DEBUG ] found configuration file at: /var/lib/ceph/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy disk list ceph-node1
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] debug : False
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] subcommand : list
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7ff1677adf50>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] host : ['ceph-node1']
[ceph_deploy.cli][INFO ] func : <function disk at 0x7ff1677892d0>
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] default_release : False
ceph@ceph-node1's password:
[ceph-node1][DEBUG ] connection detected need for sudo
ceph@ceph-node1's password:
[ceph-node1][DEBUG ] connected to host: ceph-node1
[ceph-node1][DEBUG ] detect platform information from remote host
[ceph-node1][DEBUG ] detect machine type
[ceph-node1][DEBUG ] find the location of an executable
[ceph-node1][INFO ] Running command: sudo fdisk -l
[ceph-node1][INFO ] Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
[ceph-node1][INFO ] Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors
[ceph-node1][INFO ] Disk /dev/sdc: 100 GiB, 107374182400 bytes, 209715200 sectors
[ceph-node1][INFO ] Disk /dev/sde: 100 GiB, 107374182400 bytes, 209715200 sectors
[ceph-node1][INFO ] Disk /dev/sdd: 100 GiB, 107374182400 bytes, 209715200 sectors
使用 ceph-deploy disk zap 擦除各 ceph node 节点的 ceph 数据磁盘:
# 注意别把系统盘擦除了默认是 /dev/sda 因为他其实是一个格式化的过程
ceph-deploy disk zap ceph-node1 /dev/sdb
ceph-deploy disk zap ceph-node1 /dev/sdc
ceph-deploy disk zap ceph-node1 /dev/sdd
ceph-deploy disk zap ceph-node1 /dev/sde
ceph-deploy disk zap ceph-node2 /dev/sdb
ceph-deploy disk zap ceph-node2 /dev/sdc
ceph-deploy disk zap ceph-node2 /dev/sdd
ceph-deploy disk zap ceph-node2 /dev/sde
ceph-deploy disk zap ceph-node3 /dev/sdb
ceph-deploy disk zap ceph-node3 /dev/sdc
ceph-deploy disk zap ceph-node3 /dev/sdd
ceph-deploy disk zap ceph-node3 /dev/sde
ceph-deploy disk zap ceph-node4 /dev/sdb
ceph-deploy disk zap ceph-node4 /dev/sdc
ceph-deploy disk zap ceph-node4 /dev/sdd
ceph-deploy disk zap ceph-node4 /dev/sde
3.4.21 添加 OSD
ceph-deploy 节点上操作
数据分类保存方式:
Data:即 ceph 保存的对象数据 Block: rocks DB 数据即元数据 block-wal:数据库的 wal 日志
添加到 osd 之后他的 osd-id 默认是从 0 开始顺序使用,第二个磁盘的话就是 id=1 了,第三个磁盘就是 id=2 以此类推,该 id 的作用是区分当前 ceph 集群中的每个磁盘的管理
# 添加所有 ceph-node 主机磁盘到 OSD 中服务中
ceph-deploy osd create ceph-node1 --data /dev/sdb
ceph-deploy osd create ceph-node1 --data /dev/sdc
ceph-deploy osd create ceph-node1 --data /dev/sdd
ceph-deploy osd create ceph-node1 --data /dev/sde
ceph-deploy osd create ceph-node2 --data /dev/sdb
ceph-deploy osd create ceph-node2 --data /dev/sdc
ceph-deploy osd create ceph-node2 --data /dev/sdd
ceph-deploy osd create ceph-node2 --data /dev/sde
ceph-deploy osd create ceph-node3 --data /dev/sdb
ceph-deploy osd create ceph-node3 --data /dev/sdc
ceph-deploy osd create ceph-node3 --data /dev/sdd
ceph-deploy osd create ceph-node3 --data /dev/sde
ceph-deploy osd create ceph-node4 --data /dev/sdb
ceph-deploy osd create ceph-node4 --data /dev/sdc
ceph-deploy osd create ceph-node4 --data /dev/sdd
ceph-deploy osd create ceph-node4 --data /dev/sde
通过 ceph -s
查看是否添加 osd 成功
[23:09:08 ceph@ceph-deploy ceph-cluster]$ceph -s
cluster:
id: 14ce1d1a-3323-4337-963a-f96484ddd363
health: HEALTH_OK # 心跳检测 OK
services:
mon: 1 daemons, quorum ceph-mon1 (age 4h)
mgr: ceph-mgr1(active, since 47m), standbys: ceph-mgr2
osd: 16 osds: 16 up (since 30s), 16 in (since 38s) # 提示 osd 总数为 16,16 个在线
data:
pools: 1 pools, 1 pgs
objects: 0 objects, 0 B
usage: 109 MiB used, 1.6 TiB / 1.6 TiB avail
pgs: 1 active+clean
切换到 ceph-node1 节点上通过ps -ef | grep osd
会发现一共有个 4 个 osd 进程分别对应 id 也对应 4 块不同的磁盘
root@ceph-node1:~# ps -ef | grep osd
ceph 18772 1 0 23:06 ? 00:00:01 /usr/bin/ceph-osd -f --cluster ceph --id 0 --setuser ceph --setgroup ceph
ceph 20473 1 0 23:06 ? 00:00:01 /usr/bin/ceph-osd -f --cluster ceph --id 1 --setuser ceph --setgroup ceph
ceph 22149 1 0 23:06 ? 00:00:01 /usr/bin/ceph-osd -f --cluster ceph --id 2 --setuser ceph --setgroup ceph
ceph 23830 1 0 23:06 ? 00:00:01 /usr/bin/ceph-osd -f --cluster ceph --id 3 --setuser ceph --setgroup ceph
ceph 中有个命令能够查出我的 osd id 对应到那个 ceph-node 节点上的那个磁盘,然后我们需要统计下来,以防止工作中 ceph 磁盘坏了好及时维修