Ceph添加/删除Mon(ceph.conf)

时间:2021-10-26 03:28:54

操作环境

ceph 0.87.7

Openstack icehouse

Centos 6.5 x86_64

 

当前ceph配置文件如下

[global]
pid file = /var/run/ceph/$name.pid
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
keyring = /etc/ceph/keyring.admin
[mon]
mon data = /mon
mon clock drift allowed = .25
[mon.alpha]
host = mon1
mon addr = 10.10.200.3:6789
[mon.beta]
host = mon2
mon addr = 10.10.200.4:6789
[mds]
[osd]
osd data = /osd/$name
osd mkfs type = xfs
osd journal = /osd/$name/journal
keyring = /etc/ceph/keyring.$name
osd crush update on start = false
[osd.0]
host = osd1
devs = /dev/vdb
[osd.1]
host = osd2
devs = /dev/vdb
[osd.2]
host = osd3
devs = /dev/vdb
[osd.3]
host = osd4
devs = /dev/vdb
[osd.4]
host = osd5
devs = /dev/vdb
[osd.5]
host = osd6
devs = /dev/vdb

操作步骤

添加Mon

1.查看当前mon节点

[root@mon1 ~]# ceph mon stat
e3: 2 mons at {alpha=10.10.200.3:6789/0,beta=10.10.200.4:6789/0}, election epoch 88, quorum 0,1 alpha,beta

2.例如添加mon.gamma节点,首先在ceph.conf添加mon.gamma配置

[mon.gamma]
host = mon3
mon addr = 10.10.200.10:6789

3.获取mon的keyring

[root@mon1 ~]# ceph auth get mon. -o /tmp/keyring
exported keyring for mon.

4.获取mon的map

[root@mon1 ~]# ceph mon getmap -o /tmp/mapfile
got monmap epoch 3

5.初始化mon.gamma节点的数据目录

[root@mon1 ~]# ceph-mon -i gamma --mkfs --monmap /tmp/mapfile --keyring /tmp/keyring 
ceph-mon: created monfs at /mon for mon.gamma

6.添加mon.gamma节点至ceph cluster中

[<a target=_blank href="mailto:root@mon3">root@mon3</a> ~]# ceph mon add gamma 10.10.200.10:6789
added mon.gamma at 10.10.200.10:6789/0

7.启动mon.gamma

root@mon3 ~]# ceph-mon -i gamma --public-addr 10.10.200.10:6789

8.查看当前mon节点

[root@mon1 ~]# ceph mon stat
e4: 3 mons at {alpha=10.10.200.3:6789/0,beta=10.10.200.4:6789/0,gamma=10.10.200.10:6789/0}, election epoch 94, quorum 0,1,2 alpha,beta,gamma

 

删除Mon

1.查看当前mon节点

[root@mon1 ~]# ceph mon stat
e2: 3 mons at {alpha=10.10.200.3:6789/0,beta=10.10.200.4:6789/0,gamma=10.10.200.10:6789/0}, election epoch 84, quorum 0,1,2 alpha,beta,gamma


2.例如删除mon.gamma节点,首先停止mon.gamma节点

[root@mon1 ~]# /etc/init.d/ceph -a stop mon.gamma
=== mon.gamma ===
Stopping Ceph mon.gamma on mon3...kill 1576...done


3.将mon.gamma节点从ceph cluster中删除掉

[root@mon1 ~]# ceph mon remove gamma
removed mon.gamma at 10.10.200.10:6789/0, there are now 2 monitors


4.在ceph.conf配置文件中删除mon.gamma字段

 

5.查看当前mon节点

[root@mon1 ~]# ceph mon stat
e3: 2 mons at {alpha=10.10.200.3:6789/0,beta=10.10.200.4:6789/0}, election epoch 88, quorum 0,1 alpha,beta