• Ceph的Mon数据重新构建工具


    关于mon的数据的问题,一般正常情况下都是配置的3个mon的,但是还是有人会担心 Mon 万一三个同时都挂掉了怎么办,那么集群所有的数据是不是都丢了,关于后台真实数据恢复,有去后台取对象,然后一个个拼接起来的方案,这个是确定可以成功的,但是这个方法对于生产的集群耗时巨大,并且需要导出数据,然后又配置新的集群,工程比较耗大,考虑到这个问题,Ceph 的中国(Redhat)的一位开发者 tchaikov 就写了一个新的工具,来对损坏的MON的数据进行原集群的重构,这个比起其他方案要好很多,本篇将讲述怎么使用这个工具,代码已经合并到 Ceph 的master分支当中去了

    关于这个工具相关的issue

    打包一个合进新代码的master版本的ceph包

    从github上面获取代码

    默认的分支就是master的直接去clone就可以了

    [root@lab8106 ~]# git clone https://github.com/ceph/ceph.git
    

    检查是否是master分支

    [root@lab8106 ~]# cd ceph
    [root@lab8106 ceph]# git branch
    * master
    

    检查代码是否是合进需要的代码了

    [root@lab8106 ~]# cat ceph/doc/rados/troubleshooting/troubleshooting-mon.rst |grep rebuild
      # rebuild the monitor store from the collected map, if the cluster does not
      # i.e. use "ceph-monstore-tool /tmp/mon-store rebuild" instead
      ceph-monstore-tool /tmp/mon-store rebuild -- --keyring /path/to/admin.keyring
    #. then rebuild the store
    

    因为这个代码是最近才合进去的 ,所以一定要检查代码的正确性

    创建一个源码包

    进入到代码的根目录,修改make-dist文件里面的一个地方(第46行),否则打出来的包可能没有版本号,因为打包的时候检查了有没有git目录
    修改下面

    #tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/src/ceph_ver.h $outfile/ceph.spec
    tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/src/ceph_ver.h $outfile/ceph.spec $outfile/.git
    

    如果不改,就可能出现

    [root@lab8106 ceph]# ceph -v
    ceph version HEAD-HASH-NOTFOUND (GITDIR-NOTFOUND)
    

    创建源码包

    [root@lab8106 ceph]#cd ceph
    [root@lab8106 ceph]#./make-dist
    [root@lab8106 ceph]# cp ceph-11.0.0-2460-g22053d0.tar.bz2 /root/rpmbuild/SOURCES/
    [root@lab8106 ceph]# cp -f ceph.spec /root/rpmbuild/SPECS/
    [root@lab8106 ceph]# rpmbuild -bb /root/rpmbuild/SPECS/ceph.spec
    

    执行完了以后就去这个路径取包

    [root@lab8106 ceph]# ll /root/rpmbuild/RPMS/x86_64/
    total 1643964
    -rw-r--r-- 1 root root      1972 Sep 20 10:32 ceph-11.0.0-2460.g22053d0.el7.centos.x86_64.rpm
    -rw-r--r-- 1 root root  42259096 Sep 20 10:32 ceph-base-11.0.0-2460.g22053d0.el7.centos.x86_64.rpm
    -rw-r--r-- 1 root root 320843080 Sep 20 10:35 ceph-common-11.0.0-2460.g22053d0.el7.centos.x86_64.rpm
    -rw-r--r-- 1 root root  58138088 Sep 20 10:36 ceph-mds-11.0.0-2460.g22053d0.el7.centos.x86_64.rpm
    ···
    

    准备测试环境

    使用打好的包进行集群的配置,创建一个正常的集群,这里就不讲述怎么配置集群了

    模拟mon损坏

    [root@lab8106 ceph]# systemctl stop ceph-mon@lab8106
    [root@lab8106 ceph]# mv /var/lib/ceph/mon/ceph-lab8106/  /var/lib/ceph/mon/ceph-lab8106bk
    

    按上面的操作以后,mon的数据相当于全部丢失了,本测试环境是单mon的,多mon原理一样

    重构数据

    创建一个临时目录,停止掉所有的osd,这个地方因为mon已经完全挂掉了,所以停止所有osd也没什么大的影响了

    [root@lab8106 ceph]# mkdir /tmp/mon-store
    [root@lab8106 ceph]# ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-0/ --op update-mon-db --mon-store-path /tmp/mon-store/
    [root@lab8106 ceph]# ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-1/ --op update-mon-db --mon-store-path /tmp/mon-store/
    

    注意如果有多台OSD机器,那么在一台台的OSD主机进行上面的操作,这个目录的数据要保持递增的,也就是一直对着这个目录弄,假如换了一台机器那么先把这个数据传递到另外一台机器

    root@lab8106 ~]# rsync -avz /tmp/mon-store 192.168.8.107:/tmp/mon-store
    sending incremental file list
    created directory /tmp/mon-store
    mon-store/
    mon-store/kv_backend
    mon-store/store.db/
    mon-store/store.db/000005.sst
    mon-store/store.db/000008.sst
    mon-store/store.db/000009.log
    mon-store/store.db/CURRENT
    mon-store/store.db/LOCK
    mon-store/store.db/MANIFEST-000007
    
    sent 11490 bytes  received 153 bytes  7762.00 bytes/sec
    total size is 74900  speedup is 6.43
    

    等192.168.8.106的机器全部做完了,然后这个/tmp/mon-store传递到了192.168.8.107的机器上,然后再开始做192.168.8.107这台机器的,等全部做外了,把这个/tmp/mon-store弄到需要恢复mon的机器上

    根据获得的数据进行重构

    [root@lab8106 ~]# mkdir /var/lib/ceph/mon/ceph-lab8106
    [root@lab8106 ~]# ceph-monstore-tool /tmp/mon-store rebuild
    [root@lab8106 ~]# cp -ra /tmp/mon-store/* /var/lib/ceph/mon/ceph-lab8106
    [root@lab8106 ~]# touch /var/lib/ceph/mon/ceph-lab8106/done
    [root@lab8106 ~]# touch /var/lib/ceph/mon/ceph-lab8106/systemd
    [root@lab8106 ~]# chown ceph:ceph -R /var/lib/ceph/mon/
    

    启动mon

    [root@lab8106 ~]# systemctl restart ceph-mon@lab8106
    

    检查状态

    [root@lab8106 ~]# ceph -s
    

    可以看到可以好了,在实践过程中,发现如果对修复的数据,马上进行破坏,再次进行修复的时候,就无法恢复了,应该是个bug,已经提交给作者 Issue:11226

    无法恢复的数据

    • pg settings: the full ratio and nearfull ratio 设置会丢失,这个无关紧要,再设置一次就可以了

    MDS Maps: the MDS maps are lost.

    总结

    因为工具才出来,可能难免有些bug,这个是为未来提供一种恢复数据的方式,使得 Ceph 变得更加的健壮

    附加知识

    如果指定ceph版本进行编译

    git clone https://github.com/ceph/ceph.git
    git checkout -b myceph v10.2.3
    git submodule update --init --recursive
    

    v10.2.3为发行版本的tag,也就是release的版本号码,这个操作是切换到指定的tag,并且下载依赖的一些模块

    变更记录

    Why Who When
    创建 武汉-运维-磨渣 2016-09-20
    增加git版本选择 武汉-运维-磨渣 2016-10-12
  • 相关阅读:
    【React Native】某个页面禁用物理返回键
    【React Native】DeviceEventEmitter监听通知及带参数传值
    转载【React Native代码】手写验证码倒计时组件
    【React Native】 中设置 APP 名称、应用图标、为安卓添加启动图
    【React Native错误集】* What went wrong: Execution failed for task ':app:installDebug'.
    【React Native错误集】Import fails with "Failed to execute 'ImportScripts' on 'WorkerGlobalScope'"
    【React Native错误集】Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start of app
    「React Native笔记」在React的 setState 中操作数组和对象的多种方法(合集)
    【React Native】Error: Attribute application@allowBackup value=(false) from AndroidManifest.xml
    坚果云如何使用二次验证码/谷歌身份验证器/两步验证/虚拟MFA?
  • 原文地址:https://www.cnblogs.com/zphj1987/p/13575370.html
Copyright © 2020-2023  润新知