集群管理
在线扩容(TiDB/TiKV/PD)
第一步: 编辑扩容配置文件(scale-out.yaml)
[root@tiup ~]# more scale-out.yaml
pd_servers:
- host: 192.168.16.15
ssh_port: 22
client_port: 2379
peer_port: 2380
tidb_servers:
- host: 192.168.16.15
ssh_port: 22
port: 4000
status_port: 10080
tikv_servers:
- host: 192.168.16.15
ssh_port: 22
port: 20160
status_port: 20180
monitoring_servers:
- host: 192.168.16.15
grafana_servers:
- host: 192.168.16.15
alertmanager_servers:
- host: 192.168.16.15
第二步: 运行扩容命令
[root@tiup ~]# tiup cluster scale-out tidb-test ./scale-out.yaml
第三步: 验证
[root@tiup ~]# tiup cluster list tidb-test
在线缩容(TiDB/TiKV/PD)
第一步:查看集群信息
[root@tiup ~]# tiup cluster display tidb-test
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.12.3/tiup-cluster display tidb-test
Cluster type: tidb
Cluster name: tidb-test
Cluster version: v6.1.6
Deploy user: root
SSH type: builtin
Grafana URL: http://192.168.16.10:3000,http://192.168.16.15:3000
192.168.16.10:9093 alertmanager 192.168.16.10 9093/9094 linux/x86_64 ager-9093 /tidb-deploy/alertmanager-9093
192.168.16.15:9093 alertmanager 192.168.16.15 9093/9094 linux/x86_64 ager-9093 /tidb-deploy/alertmanager-9093
192.168.16.10:3000 grafana 192.168.16.10 3000 linux/x86_64 /tidb-deploy/grafana-3000
192.168.16.15:3000 grafana 192.168.16.15 3000 linux/x86_64 /tidb-deploy/grafana-3000
192.168.16.10:2379 pd 192.168.16.10 2379/2380 linux/x86_64 /tidb-deploy/pd-2379
192.168.16.15:2379 pd 192.168.16.15 2379/2380 linux/x86_64 /tidb-deploy/pd-2379
192.168.16.10:9090 prometheus 192.168.16.10 9090/12020 linux/x86_64 us-9090 /tidb-deploy/prometheus-9090
192.168.16.15:9090 prometheus 192.168.16.15 9090/12020 linux/x86_64 us-9090 /tidb-deploy/prometheus-9090
192.168.16.10:4000 tidb 192.168.16.10 4000/10080 linux/x86_64 /tidb-deploy/tidb-4000
192.168.16.15:4000 tidb 192.168.16.15 4000/10080 linux/x86_64 /tidb-deploy/tidb-4000
192.168.16.10:20160 tikv 192.168.16.10 20160/20180 linux/x86_64 60 /tidb-deploy/tikv-20160
192.168.16.15:20160 tikv 192.168.16.15 20160/20180 linux/x86_64 60 /tidb-deploy/tikv-20160
第二步: 执行缩容动作
[root@tiup ~]# tiup cluster scale-in tidb-test --node 192.168.16.15:4000
第三步: 检查集群状态
[root@tiup ~]# tiup cluster display tidb-test
在线扩容(TiFlash)
第一步: 确认当前TiDB的版本支持TiFlash
第二步: enable-placement-rules 参数开启
第三步: 编辑扩容配置文件(scale-out.yaml)
tiflash_servers:
- host: 10.10.1.4
第四步: 运行扩容命令
tiup cluster scale-out tidb-test scale-out.yaml
第五步: 确认新节点是否加入
tiup cluster display tidb-test
在线缩容(TiFlash)
第一步: 根据TiFlash剩余节点数调整数据表的副本数
alter table tbl set tiflash replica 0;
第二步: 确认表的副本数确实被删除
select * from information_schema.tiflash_replica where table_schema=‘’ and table_name=‘’
第三步: 查看节点ID信息
tiup cluster scale-out tidb-test scale-out.yaml
第四步: 运行缩容命令
tiup cluster scale-in tidb-test --node localhost:port
重命名集群
[root@tiup ~]# tiup cluster rename tidb-test tidb-test1
清理集群数据
启动集群以后,可以通过如下命令清理集群数据:
tiup cluster clean ${
cluster-name} --xx
-- log : 清理日志
-- data : 清理数据
-- all : 清理日志和数据
销毁集群
tiup cluster destroy ${
cluster-name}
时区的修改
time_zone= 'UTF'
time_zone='+5:00'
清理节点信息
tiup cluster prune tidb-test