生产环境下,如何缩减机器?
1、首先是检查出来那个tikv节点需要缩减
[tidb@:vg_adn_tidbCkhsTest:172.31.30.62 ~/tidb-ansible]$/home/tidb/tidb-ansible/resources/bin/pd-ctl -u "http://172.31.30.62:2379" -d store { "count": 5, "stores": [ { "store": { "id": 1, "address": "172.31.17.203:20171", "labels": [ { "key": "host", "value": "tikv3" } ], "version": "2.1.0-rc.5", "state_name": "Up" }, "status": { "capacity": "2.0 TiB", "available": "1.9 TiB", "leader_count": 297, "leader_weight": 1, "leader_score": 25792, "leader_size": 25792, "region_count": 1533, "region_weight": 1, "region_score": 127200, "region_size": 127200, "start_ts": "2019-01-02T12:56:00+08:00", "last_heartbeat_ts": "2019-01-02T14:42:25.586838854+08:00", "uptime": "1h46m25.586838854s" } }, "version": "2.1.0-rc.5", "state_name": "Up" }, "status": { "capacity": "2.0 TiB", "available": "1.9 TiB", "leader_count": 344, "leader_weight": 1, "leader_score": 25450, "leader_size": 25450, "region_count": 807, "region_weight": 1, "region_score": 63203, "region_size": 63203, "start_ts": "2019-01-02T12:53:05+08:00", "last_heartbeat_ts": "2019-01-02T14:42:33.18874117+08:00", "uptime": "1h49m28.18874117s" } }, { "store": { "id": 7, "address": "172.31.26.133:20172", "labels": [ { "key": "host", "value": "tikv2" } ], "version": "2.1.0-rc.5", "state_name": "Up" }, "status": { "capacity": "955 GiB", "available": "945 GiB", "leader_count": 313, "leader_weight": 1, "leader_score": 25532, "leader_size": 25532, "region_count": 726, "region_weight": 1, "region_score": 63997, "region_size": 63997, "start_ts": "2019-01-02T12:54:51+08:00", "last_heartbeat_ts": "2019-01-02T14:42:29.339673448+08:00", "uptime": "1h47m38.339673448s" } } ] }
我想缩减id为7的机器:
2、找出id号后开始缩减,
[tidb@:vg_adn_tidbCkhsTest:172.31.30.62 ~/tidb-ansible]$/home/tidb/tidb-ansible/resources/bin/pd-ctl -u "http://172.31.30.62:2379" -d store delete 7 Success!
3、检测该机器是否已经真正下线,
[tidb@:vg_adn_tidbCkhsTest:172.31.30.62 ~/tidb-ansible]$/home/tidb/tidb-ansible/resources/bin/pd-ctl -u "http://172.31.30.62:2379" -d store 7 { "store": { "id": 7, "address": "172.31.26.133:20172", "state": 1, "labels": [ { "key": "host", "value": "tikv2" } ], "version": "2.1.0-rc.5", "state_name": "Offline" },
注意:此处显示为“Offline”并不表示真正的下线,下线需要几分钟,因此我们过10分钟再来查看一下
4、再次检查机器
[tidb@:vg_adn_tidbCkhsTest:172.31.30.62 ~/tidb-ansible]$/home/tidb/tidb-ansible/resources/bin/pd-ctl -u "http://172.31.30.62:2379" -d store 7 { "key": "host", "value": "tikv2" } ], "version": "2.1.0-rc.5", "state_name": "Tombstone"
注意:只有当此处变成“Tombstone”才表示机器真正的下线,接下来我们可以继续进行下一步了
4、下线成功后,就可以单独关闭这个节点了
ansible-playbook stop.yml -l 172.16.10.9
5、更新inventory.ini文件,将这个机器注释掉。
6、更新grafana
ansible-playbook rolling_update_monitor.yml --tags=prometheus