本文由Ceph中国社区-Leon 翻译、半天河校稿。 英文出处:Ceph ansible can now shrink your cluster 欢迎加入CCTG
Ceph ansible正在快速赶上ceph-deploy的特性。上周,我讨论了对dm-crypt的支持。直到最近,才实现了收缩一个Ceph集群的特性,移除一个或多个监控节点/OSD节点。我们来看下这个新特性。
我最近合并了两个新的playbook,一个用来收缩监控节点,另一个则用来收缩OSD节点。我发现在同一个playbook中做这两件事会让人困惑。尽管这些playbook的大部分是相同的,由于以下几个原因,我还是觉得把两个分开更合理:
- 同时移除mon和osd的情况很罕见,这种情况下你可能需要purge-cluster这个playbook(此处作者给的链接有误,去github上的ceph仓库找了有效的链接——译者注)
- 收缩本身就是一个复杂的进程,所以为了防止重叠我们让它分开处理
运行收缩集群的playbook之前:
1 2 3 4 5 6 7 8 |
cluster <span class="hljs-number" style="color:teal;line-height:1.6;">4</span>c616836-<span class="hljs-number" style="color:teal;line-height:1.6;">8</span>b43-<span class="hljs-number" style="color:teal;line-height:1.6;">4</span>dd0-be24-<span class="hljs-number" style="color:teal;line-height:1.6;">1</span>cdefa07a1fe health HEALTH_WARN clock skew detected on mon.ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">02</span>, mon.ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">03</span> Monitor clock skew detected monmap e1: <span class="hljs-number" style="color:teal;line-height:1.6;">3</span> mons at {ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">01</span>=<span class="hljs-number" style="color:teal;line-height:1.6;">172.16</span><span class="hljs-number" style="color:teal;line-height:1.6;">.41</span><span class="hljs-number" style="color:teal;line-height:1.6;">.28</span>:<span class="hljs-number" style="color:teal;line-height:1.6;">6789</span>/<span class="hljs-number" style="color:teal;line-height:1.6;">0</span>,ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">02</span>=<span class="hljs-number" style="color:teal;line-height:1.6;">172.16</span><span class="hljs-number" style="color:teal;line-height:1.6;">.41</span><span class="hljs-number" style="color:teal;line-height:1.6;">.63</span>:<span class="hljs-number" style="color:teal;line-height:1.6;">6789</span>/<span class="hljs-number" style="color:teal;line-height:1.6;">0</span>,ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">03</span>=<span class="hljs-number" style="color:teal;line-height:1.6;">172.16</span><span class="hljs-number" style="color:teal;line-height:1.6;">.41</span><span class="hljs-number" style="color:teal;line-height:1.6;">.67</span>:<span class="hljs-number" style="color:teal;line-height:1.6;">6789</span>/<span class="hljs-number" style="color:teal;line-height:1.6;">0</span>} election epoch <span class="hljs-number" style="color:teal;line-height:1.6;">6</span>, quorum <span class="hljs-number" style="color:teal;line-height:1.6;">0</span>,<span class="hljs-number" style="color:teal;line-height:1.6;">1</span>,<span class="hljs-number" style="color:teal;line-height:1.6;">2</span> ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">01</span>,ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">02</span>,ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">03</span> fsmap e3: <span class="hljs-number" style="color:teal;line-height:1.6;">0</span>/<span class="hljs-number" style="color:teal;line-height:1.6;">0</span>/<span class="hljs-number" style="color:teal;line-height:1.6;">1</span> up osdmap e35: <span class="hljs-number" style="color:teal;line-height:1.6;">7</span> osds: <span class="hljs-number" style="color:teal;line-height:1.6;">7</span> up, <span class="hljs-number" style="color:teal;line-height:1.6;">7</span> in flags sortbitwise pgmap v3885: <span class="hljs-number" style="color:teal;line-height:1.6;">320</span> pgs, <span class="hljs-number" style="color:teal;line-height:1.6;">3</span> pools, <span class="hljs-number" style="color:teal;line-height:1.6;">0</span> bytes data, <span class="hljs-number" style="color:teal;line-height:1.6;">0</span> objects <span class="hljs-number" style="color:teal;line-height:1.6;">271</span> MB used, <span class="hljs-number" style="color:teal;line-height:1.6;">132</span> GB / <span class="hljs-number" style="color:teal;line-height:1.6;">132</span> GB avail <span class="hljs-number" style="color:teal;line-height:1.6;">320</span> active+clean |
收缩监控节点
比如我想移除ceph-mon-02监控节点,我需要运行以下命令:
1 |
$ ansible-playbook shrink-mon.yml -e ireallymeanit=<span class="hljs-literal" style="line-height:1.6;">yes</span> -e mon_host=ceph-mon-<span class="hljs-number" style="color:teal;line-height:1.6;">02</span> Are you sure you want to shrink the cluster? [<span class="hljs-literal" style="line-height:1.6;">no</span>]: <span class="hljs-literal" style="line-height:1.6;">yes</span> |
显然,需要适当的主机名解析来连接到ceph-mon-02。playbook首先就会测试这个解析,如果我们没办法解析,我们就停止后续操作并报告该playbook执行失败。
收缩OSD节点
对象存储的守护进程有点难办,每个OSD节点需要有ceph的admin密钥来执行这个操作。众所周知的最佳实践是,admin不应该在OSD节点上,这也是出于安全考虑。这个playbook的目的不是要毁了你的环境,所以它会检查密钥是否存在于OSD节点,如果不存在,就执行失败,然后你需要将admin密钥复制到适当的节点上。
所以记住,在执行playbook之前,确保admin密钥在OSD节点上,还有,完成后不要忘了移除掉。
这是我的OSD树:
1 2 |
ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY -<span class="hljs-number" style="color:teal;line-height:1.6;">1</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.12946</span> root <span class="hljs-keyword" style="font-weight:700;line-height:1.6;">default</span> -<span class="hljs-number" style="color:teal;line-height:1.6;">2</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.05548</span> host ceph-osd-<span class="hljs-number" style="color:teal;line-height:1.6;">01</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.0</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">3</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.3</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">6</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.6</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> -<span class="hljs-number" style="color:teal;line-height:1.6;">3</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.03699</span> host ceph-osd-<span class="hljs-number" style="color:teal;line-height:1.6;">02</span> <span class="hljs-number" style="color:teal;line-height:1.6;">2</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.2</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">5</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.5</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> -<span class="hljs-number" style="color:teal;line-height:1.6;">4</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.03699</span> host ceph-osd-<span class="hljs-number" style="color:teal;line-height:1.6;">03</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.1</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">4</span> <span class="hljs-number" style="color:teal;line-height:1.6;">0.01849</span> osd<span class="hljs-number" style="color:teal;line-height:1.6;">.4</span> up <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> <span class="hljs-number" style="color:teal;line-height:1.6;">1.00000</span> |
我想移除OSD 6,所以我像这样运行playbook:
1 |
$ ansible-playbook shrink-osd.yml -e osd_ids=<span class="hljs-number" style="color:teal;line-height:1.6;">6</span> Are you sure you want to shrink the cluster? [<span class="hljs-literal" style="line-height:1.6;">no</span>]: <span class="hljs-literal" style="line-height:1.6;">yes</span> |
我觉得,这个最新的补丁基本完成了ceph-ansible对ceph-deploy一系列的追赶。有了这个,完全达到了特性对等。