本地化部署的 TiDB 集群运维
查看集群列表
- tiup cluster list
检查集群运行状态
- tiup cluster display ${cluster_name}
启动/停止集群
-
启动顺序 PD - TiKV - Pump - TiDB - TiFlash - Drainer
-
关闭顺序 Drainer - TiFlash - TiDB - Pump - TiKV - PD
-
tiup cluster start/stop <cluster_name>
-
tiup cluster start/stop <cluster_name> -R <Role>
-
tiup cluster start/stop <cluster_name> -N <node_id1>,<node_id2>
修改集群参数
- tiup cluster edit-config <cluster_name>
修改完参数后需滚动重启生效
- tiup cluster reload <cluster_name> [-N <nodes>] [-R <roles>]
对TiDB/PD/TiKV节点进行扩容操作
-
tiup cluster scale-out <cluster_name> scale-out-tidb.yaml
-
扩容TiFlash节点的操作
-
需要4.0以上版本,enable-placement-rules参数为True
-
命令与TiDB等组件扩容命令一致
对TiDB/PD/TiKV节点进行缩容操作
- tiup cluster scale-in <cluster_name> --node <node_id>
- node_id 可以通过 tiup cluster display <cluster_name>获取
对TiFlash进行缩容
- 将副本数设置为0 (alter table <db_name>.<table_name> set tiflash replica 0;)
- 检查副本是否真的被删除(select * from information_schema.tiflash_replica where table_schema=‘<db_name>’ and table_name=’<table_name>’;)
- 查看对应的ID (tiup cluster display <cluster_name>)
- 进行缩容操作(tiup cluster scale-in <cluster_name> --node <node_id>)
集群管理工具
- tiup ctl [tidb/pd/tikv/binlog/etcd]
Hot-Fix操作
- tiup cluster path <cluster_name> <package_path> [flags]