Ceph群集维护简明手册 (2)前言 (2)MON (2)MON节点添加 (3)MON节点删除 (4)MON故障恢复 (4)OSD (6)OSD添加 (6)OSD删除 (6)日志迁移 (6)硬盘更换 (7)RBD (7)块存储的基本操作 (7)快照 (10)导入导出 (11)增量备份与恢复 (12)Ceph群集维护简明手册作者: 普通人前言本手册针对已部署完成ceph集群进行阐述(通过ceph-deploy工具),部署架构图如下:MON环境配置节点 主机名 Public ip address Cluster ip address Admin/ceph ubuntu-ceph-06 192.168.0.24 10.10.0.6ceph ubuntu-ceph-07 192.168.0.25 10.10.0.7ceph ubuntu-ceph-06 192.168.0.26 10.10.0.8在管理节点的配置目录下,使用ceph-depoloy工具添加新的mon节点。
1.更新配置文件,添加新mon的信息2.推送新的配置文件到所有节点,或者在添加时覆盖(ceph-deploy会提示)3.使用ceph-deploy工具添加MON新节点root@ubuntu-ceph-06:/opt/ceph# ceph-deploy mon create ubuntu-ceph-08[ceph_deploy.cli][INFO ] Invoked (1.4.0): /usr/bin/ceph-deploy mon create ubuntu-ceph-08 [ceph_deploy.mon][DEBUG ] Deploying mon, cluster ceph hosts ubuntu-ceph-08[ceph_deploy.mon][DEBUG ] detecting platform for host ubuntu-ceph-08 ...[ubuntu-ceph-08][DEBUG ] connected to host: ubuntu-ceph-08[ubuntu-ceph-08][DEBUG ] detect platform information from remote host[ubuntu-ceph-08][DEBUG ] detect machine type[ceph_deploy.mon][INFO ] distro info: Ubuntu 14.04 trusty[ubuntu-ceph-08][DEBUG ] determining if provided host has same hostname in remote [ubuntu-ceph-08][DEBUG ] get remote short hostname[ubuntu-ceph-08][DEBUG ] deploying mon to ubuntu-ceph-08[ubuntu-ceph-08][DEBUG ] get remote short hostname………………..]**************************************************************************** [ubuntu-ceph-08][DEBUG ] status for monitor: mon.ubuntu-ceph-08[ubuntu-ceph-08][DEBUG ] {[ubuntu-ceph-08][DEBUG ] "election_epoch": 0,[ubuntu-ceph-08][DEBUG ] "extra_probe_peers": [[ubuntu-ceph-08][DEBUG ] "192.168.0.24:6789/0",[ubuntu-ceph-08][DEBUG ] "192.168.0.25:6789/0"[ubuntu-ceph-08][DEBUG ] ],[ubuntu-ceph-08][DEBUG ] "monmap": {[ubuntu-ceph-08][DEBUG ] "created": "0.000000",[ubuntu-ceph-08][DEBUG ] "epoch": 14,[ubuntu-ceph-08][DEBUG ] "fsid": "fc989fb1-eea9-47f4-83e1-999c47df0930", [ubuntu-ceph-08][DEBUG ] "modified": "2015-08-19 02:50:54.480663",[ubuntu-ceph-08][DEBUG ] "mons": [[ubuntu-ceph-08][DEBUG ] {[ubuntu-ceph-08][DEBUG ] "addr": "192.168.0.24:6789/0",[ubuntu-ceph-08][DEBUG ] "name": "ubuntu-ceph-06",[ubuntu-ceph-08][DEBUG ] "rank": 0[ubuntu-ceph-08][DEBUG ] },[ubuntu-ceph-08][DEBUG ] {[ubuntu-ceph-08][DEBUG ] "addr": "192.168.0.25:6789/0",[ubuntu-ceph-08][DEBUG ] "name": "ubuntu-ceph-07",添加mon节点也可以使用ceph-deploy mon add --address [ADDRESS] hostname在管理节点的配置目录下,使用ceph-depoloy工具删除mon节点。
1.更新配置文件,删除将放弃mon的信息2.推送新的配置文件到所有节点,或者在添加时覆盖(ceph-deploy会提示)3.使用ceph-deploy工具删除MON新节点root@ubuntu-ceph-06:/opt/ceph# ceph-deploy mon destroy ubuntu-ceph-08[ceph_deploy.cli][INFO ] Invoked (1.4.0): /usr/bin/ceph-deploy mon destroy ubuntu-ceph-08 [ceph_deploy.mon][DEBUG ] Removing mon from ubuntu-ceph-08[ubuntu-ceph-08][DEBUG ] connected to host: ubuntu-ceph-08[ubuntu-ceph-08][DEBUG ] detect platform information from remote host[ubuntu-ceph-08][DEBUG ] detect machine type[ubuntu-ceph-08][DEBUG ] get remote short hostname[ubuntu-ceph-08][INFO ] Running command: ceph --cluster=ceph -n mon. -k /var/lib/ceph/mon/ceph-ubuntu-ceph-08/keyringmon remove ubuntu-ceph-08[ubuntu-ceph-08][WARNIN] removed mon.ubuntu-ceph-08 at 192.168.0.26:6789/0, there are now 2 monitors[ubuntu-ceph-08][INFO ] polling the daemon to verify it stopped[ubuntu-ceph-08][INFO ] Running command: initctl status ceph-mon cluster=ceph id=ubuntu-ceph-08[ubuntu-ceph-08][INFO ] polling the daemon to verify it stopped[ubuntu-ceph-08][INFO ] Running command: initctl status ceph-mon cluster=ceph id=ubuntu-ceph-08[ubuntu-ceph-08][INFO ] Running command: mkdir -p /var/lib/ceph/mon-removed [ubuntu-ceph-08][DEBUG ] move old monitor dataMON故障恢复一般来说,在实际运行中,ceph monitor的个数是2n+1(n>=0)个,在线上至少3个,只要正常的节点数>=n+1,ceph的paxos算法能保证系统的正常运行。
更通俗些就是正常节点的比例大于50%即可保证Ceph集群能够正常运行。
因为,对于3个节点,同时只能挂掉一个。
但是,如果屋漏偏逢雨,3个节点中挂了2个,paxos算法就无法正常进行仲裁(quorum),此时,ceph集群会阻塞对集群的操作,直到超过半数的Mon节点恢复.Ø通过monmaptool工具,根据ceph集群信息生成monmap########################################################################### ubuntu-ceph-06、ubuntu-ceph-07是将要被修复的mon节点##########root@ubuntu-ceph-06:/opt/ceph##monmaptool–create--addubuntu-ceph-07192.168.0.25:678 9 --add ubuntu-ceph-08192.168.0.26:6789 --fsid fc989fb1-eea9-47f4-83e1-999c47df0930--clobber monmapØ把monkeyring和monmap传送到Ubuntu-ceph-07节点上root@ubuntu-ceph-06# cat /var/lib/ceph/mon/ceph-ubuntu-ceph-06/keyring[mon.]key = AQDZQ8VTAAAAABAAX9HqE0NITrUt7j1w0YadvA==caps mon = "allow *"Ø在故障的mon节点初始化root@ubuntu-ceph-07#ceph-mon --cluster ceph -i ubuntu-ceph-07 --mkfs --monmapmonmap --keyringkeyringØ创建upstart空文件,实现sysV管理root@ubuntu-ceph-07:/var/lib/ceph/mon/ceph-ubuntu-ceph-07#touch upstartØ启动故障节点root@ubuntu-ceph-07# start ceph-mon id=Ubuntu-ceph-07Ø同样的方法修复ubuntu-ceph-08,最终可以使集群正常状态OSDOSD添加OSD推荐使用ceph-deploy工具来部署,默认OSD添加到CRUSH是以host为隔离域,所以,如果已经变更了crush结构,会新添加host bucket .在管理节点的配置目录下,使用ceph-depoloy工具添加新的OSD。