
TiDB
1 前言
一个问题,一篇文章,一出故事。
上一章节笔者做了扩展集群节点的实验,本章进行扩展的逆向操作,缩容集群节点。
2 最佳实践
2.1 扩展tidb集群
2.2 缩容TiDB/PD/TiKV集群角色
2.2.1 切换身份
In hd24
su - tidb
2.2.2 缩容节点的TiDB角色
In hd24
tiup cluster scale-in tidb-cluster --node hd29.cmdschool.org:4000
2.2.3 缩容节点的PD角色
In hd24
tiup cluster scale-in tidb-cluster --node hd29.cmdschool.org:2379
执行如下命令后,你还需要执行如下命令,
tiup cluster reload tidb-cluster --skip-restart
2.2.4 缩容节点的TiKV角色
In hd24
tiup cluster scale-in tidb-cluster --node hd29.cmdschool.org:20160
2.2.5 检查缩容后的状态
In hd24
tiup cluster display tidb-cluster
如果见到如下提示,
#... Total nodes: 20 There are some nodes can be pruned: Nodes: [ hd29.cmdschool.org:20160] You can destroy them with the command: `tiup cluster prune tidb-cluster`
你可以按照提示执行如下命令,
tiup cluster prune tidb-cluster
2.3 缩容TiFlash集群角色
2.3.1 切换身份
In hd24
su - tidb
2.3.2 缩容节点的TiFlash角色
In hd24
SELECT * FROM INFORMATION_SCHEMA.TIFLASH_REPLICA WHERE REPLICA_COUNT > 'tobe_left_nodes';
ALTER TABLE db.table SET tiflash replica 'new_replica_num';
2.3.3 缩容节点的TiFlash角色
In hd24
tiup cluster scale-in tidb-cluster --node hd29.cmdschool.org:9001
2.3.4 检查缩容后的状态
In hd24
tiup cluster display tidb-cluster
如果见到如下提示,
#... Total nodes: 19 There are some nodes can be pruned: Nodes: [hd29.cmdschool.org:3930] You can destroy them with the command: `tiup cluster prune tidb-cluster`
你可以按照提示执行如下命令,
tiup cluster prune tidb-cluster
参阅文档
===============
https://docs.pingcap.com/zh/tidb/stable/scale-tidb-using-tiup/
https://docs.pingcap.com/zh/tidb/stable/troubleshoot-tiflash/#%E7%BC%A9%E5%AE%B9-tiflash-%E8%8A%82%E7%82%B9%E6%85%A2
https://docs.pingcap.com/zh/tidb/stable/troubleshoot-tiflash/#%E7%BC%A9%E5%AE%B9-tiflash-%E8%8A%82%E7%82%B9%E6%85%A2
没有评论