目的
用于机房迁移
必须确保 mon 可以完成在线迁移或安全迁移
步骤
ceph mon 扩容 (新机房)
ceph mon 缩容 (旧机房)
验证 ceph 可用性
ceph mon 扩容
通过表格,参考主机信息
角色 | 主机名 | IP 地址 |
---|---|---|
原mon | ns-storage-020103 | 1.1.20.103 |
原mon | ns-storage-020104 | 1.1.20.104 |
原mon | ns-storage-020105 | 1.1.20.105 |
新mon | ns-storage-022050 | 1.1.22.50 |
新mon | ns-storage-022057 | 1.1.22.57 |
新mon | ns-storage-022058 | 1.1.22.58 |
软件安装
yum install -y ceph-common ceph
mon 扩容步骤
分别在每个新 mon 服务器上获取 mon keyring
ceph auth get mon. -o /etc/ceph/ceph.mon.keyring
分别在每个新 mon 服务器上获取 admin keryring
ceph mon getmap -o /etc/ceph/monmap
修改 ceph.conf 假入新 mon 地址 ( 注意你的 IP 对应 public network )
[global]
fsid = xxxxxx-4439-4447-8bc5-ca021be54520
mon initial members = ns-storage-020103,ns-storage-020104,ns-storage-020105,ns-storage-020050,ns-storage-020057,ns-storage-020058
mon host = 1.1.20.103,1.1.20.104,1.1.20.105,1.1.22.50,1.1.22.57,1.1.20.58
分别在各个新 mon 中创建目录
# mkdir /var/lib/ceph/mon/ceph-ns-storage-020050 -p
# mkdir /var/lib/ceph/mon/ceph-ns-storage-020057 -p
# mkdir /var/lib/ceph/mon/ceph-ns-storage-020058 -p
在各个新 mon 中各自执行 mon 初始化
ceph-mon --mkfs -i ns-storage-020050 --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
ceph-mon --mkfs -i ns-storage-020057 --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
ceph-mon --mkfs -i ns-storage-020058 --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
启动 ceph mon 前准备
touch /var/lib/ceph/mon/ceph-ns-storage-020050/{done,upstart}
touch /var/lib/ceph/mon/ceph-ns-storage-020057/{done,upstart}
touch /var/lib/ceph/mon/ceph-ns-storage-020058/{done,upstart}
cp /usr/lib/systemd/system/ceph-mon@.service /usr/lib/systemd/system/ceph-mon@ns-storage-020050.service
cp /usr/lib/systemd/system/ceph-mon@.service /usr/lib/systemd/system/ceph-mon@ns-storage-020057.service
cp /usr/lib/systemd/system/ceph-mon@.service /usr/lib/systemd/system/ceph-mon@ns-storage-020058.service
启动 ceph mon 验证
chown ceph:ceph /var/lib/ceph/mon/ -R
systemctl start ceph-mon@ns-storage-020050.service
其他 CEPH MON 启动同理
校验 ceph 状态
# ceph -s
cluster:
id: 3e34940b-4439-4447-8bc5-ca021be54520
health: HEALTH_WARN
services:
mon: 6 daemons, quorum ns-storage-020103,ns-storage-020104,ns-storage-020105,ns-storage-020050,ns-storage-020057,ns-storage-020058
mgr: ns-storage-020103(active), standbys: ns-storage-020104, ns-storage-020105
osd: 15 osds: 15 up, 15 in
结论
CEPH mon 添加已经成功
旧 ceph mon 不需要重启即可发现并找到新 ceph mon
ceph mon 缩容
对旧 ceph mon 进行删除缩容操作
修改 ceph.conf 配置
[global]
fsid = xxxxxx-4439-4447-8bc5-ca021be54520
mon initial members = ns-storage-020050,ns-storage-020057,ns-storage-020058
mon host = 1.1.22.50,1.1.22.57,1.1.20.58
从 monmap 中删除旧 ceph mon 信息
# monmaptool --rm ns-storage-020103 /etc/ceph/monmap
monmaptool: monmap file /etc/ceph/monmap
monmaptool: removing ns-storage-020103
monmaptool: writing epoch 0 to /etc/ceph/monmap (5 monitors)
# monmaptool --rm ns-storage-020104 /etc/ceph/monmap
monmaptool: monmap file /etc/ceph/monmap
monmaptool: removing ns-storage-020104
monmaptool: writing epoch 0 to /etc/ceph/monmap (4 monitors)
# monmaptool --rm ns-storage-020105 /etc/ceph/monmap
monmaptool: monmap file /etc/ceph/monmap
monmaptool: removing ns-storage-020105
monmaptool: writing epoch 0 to /etc/ceph/monmap (3 monitors)
复制 cephmon 及 ceph.conf 至所有的 ceph osd, ceph mon 中
# scp /etc/ceph/monmap /etc/ceph/ceph.conf 1.1.22.50:/etc/ceph
# scp /etc/ceph/monmap /etc/ceph/ceph.conf 1.1.22.57:/etc/ceph
# scp /etc/ceph/monmap /etc/ceph/ceph.conf 1.1.22.58:/etc/ceph
....
其他过程忽略
安全移除 旧 ceph mon
# ceph mon remove ns-storage-020103
removing mon.ns-storage-020103 at 1.1.20.103:6789/0, there will be 5 monitors
# ceph mon remove ns-storage-020104
removing mon.ns-storage-020104 at 1.1.20.104:6789/0, there will be 4 monitors
# ceph mon remove ns-storage-020105
removing mon.ns-storage-020105 at 1.1.20.105:6789/0, there will be 3 monitors
检测 ceph mon
# ceph -s
cluster:
id: 3e34940b-4439-4447-8bc5-ca021be54520
health: HEALTH_WARN
services:
mon: 3 daemons, quorum ns-storage-020050,ns-storage-020057,ns-storage-020058
mgr: ns-storage-020103(active), standbys: ns-storage-020104, ns-storage-020105
osd: 15 osds: 15 up, 15 in
安全关闭 ceph mon
systemctl stop ns-storage-020103
systemctl stop ns-storage-020104
systemctl stop ns-storage-020105
以上已完成 ceph mon 迁移工作