使用 TiUP 扩缩容 TiDB 集群

扩容 tiflash 节点

添加节点信息到 scale-out.yml 文件

tiflash_servers:
  - host: 192.168.174.147

运行扩容命令

tiup cluster scale-out tidb-test  scale-out.yml
+ Detect CPU Arch Name
  - Detecting node 192.168.174.147 Arch info ... Done

+ Detect CPU OS Name
  - Detecting node 192.168.174.147 OS info ... Done
Please confirm your topology:
Cluster type:    tidb
Cluster name:    tidb-test
Cluster version: v8.5.1
Role     Host             Ports                            OS/Arch       Directories
----     ----             -----                            -------       -----------
tiflash  192.168.174.147  9000/3930/20170/20292/8234/8123  linux/x86_64  /tidb-deploy/tiflash-9000,/tidb-data/tiflash-9000
Attention:
    1. If the topology is not what you expected, check your yaml file.
    2. Please confirm there is no port/directory conflicts in same host.
Do you want to continue? [y/N]: (default=N) y
+ [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.146
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.146
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.147
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.147
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.147
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.146
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.147
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.146
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.145
+ [Parallel] - UserSSH: user=tidb, host=192.168.174.146
+ Download TiDB components
  - Download tiflash:v8.5.1 (linux/amd64) ... Done
+ Initialize target host environments
+ Deploy TiDB instance
  - Deploy instance tiflash -> 192.168.174.147:9000 ... Done
+ Copy certificate to remote host
+ Generate scale-out config
  - Generate scale-out config tiflash -> 192.168.174.147:9000 ... Done
+ Init monitor config
Enabling component tiflash
	Enabling instance 192.168.174.147:9000
	Enable instance 192.168.174.147:9000 success
Enabling component node_exporter
	Enabling instance 192.168.174.147
	Enable 192.168.174.147 success
Enabling component blackbox_exporter
	Enabling instance 192.168.174.147
	Enable 192.168.174.147 success
+ [ Serial ] - Save meta
+ [ Serial ] - Start new instances
Starting component tiflash
	Starting instance 192.168.174.147:9000
	Start instance 192.168.174.147:9000 success
Starting component node_exporter
	Starting instance 192.168.174.147
	Start 192.168.174.147 success
Starting component blackbox_exporter
	Starting instance 192.168.174.147
	Start 192.168.174.147 success
+ Refresh components conifgs
  - Generate config pd -> 192.168.174.145:2379 ... Done
  - Generate config pd -> 192.168.174.146:2379 ... Done
  - Generate config pd -> 192.168.174.147:2379 ... Done
  - Generate config tikv -> 192.168.174.145:20160 ... Done
  - Generate config tikv -> 192.168.174.146:20160 ... Done
  - Generate config tikv -> 192.168.174.147:20160 ... Done
  - Generate config tidb -> 192.168.174.145:4000 ... Done
  - Generate config tidb -> 192.168.174.146:4000 ... Done
  - Generate config tidb -> 192.168.174.147:4000 ... Done
  - Generate config tiflash -> 192.168.174.145:9000 ... Done
  - Generate config tiflash -> 192.168.174.146:9000 ... Done
  - Generate config tiflash -> 192.168.174.147:9000 ... Done
  - Generate config cdc -> 192.168.174.145:8300 ... Done
  - Generate config cdc -> 192.168.174.146:8300 ... Done
  - Generate config cdc -> 192.168.174.147:8300 ... Done
  - Generate config prometheus -> 192.168.174.145:9090 ... Done
  - Generate config grafana -> 192.168.174.145:3000 ... Done
  - Generate config alertmanager -> 192.168.174.145:9093 ... Done
+ Reload prometheus and grafana
  - Reload prometheus -> 192.168.174.145:9090 ... Done
  - Reload grafana -> 192.168.174.145:3000 ... Done
+ [ Serial ] - UpdateTopology: cluster=tidb-test
Scaled cluster `tidb-test` out successfully

查看集群状态

tiup cluster display tidb-test
Cluster type:       tidb
Cluster name:       tidb-test
Cluster version:    v8.5.1
Deploy user:        tidb
SSH type:           builtin
Dashboard URL:      http://192.168.174.147:2379/dashboard
Grafana URL:        http://192.168.174.145:3000
ID                     Role          Host             Ports                            OS/Arch       Status  Data Dir                      Deploy Dir
--                     ----          ----             -----                            -------       ------  --------                      ----------
192.168.174.145:9093   alertmanager  192.168.174.145  9093/9094                        linux/x86_64  Up      /tidb-data/alertmanager-9093  /tidb-deploy/alertmanager-9093
192.168.174.145:8300   cdc           192.168.174.145  8300                             linux/x86_64  Up      /tidb-data/cdc-8300           /tidb-deploy/cdc-8300
192.168.174.146:8300   cdc           192.168.174.146  8300                             linux/x86_64  Up      /tidb-data/cdc-8300           /tidb-deploy/cdc-8300
192.168.174.147:8300   cdc           192.168.174.147  8300                             linux/x86_64  Up      /tidb-data/cdc-8300           /tidb-deploy/cdc-8300
192.168.174.145:3000   grafana       192.168.174.145  3000                             linux/x86_64  Up      -                             /tidb-deploy/grafana-3000
192.168.174.145:2379   pd            192.168.174.145  2379/2380                        linux/x86_64  Up|L    /tidb-data/pd-2379            /tidb-deploy/pd-2379
192.168.174.146:2379   pd            192.168.174.146  2379/2380                        linux/x86_64  Up      /tidb-data/pd-2379            /tidb-deploy/pd-2379
192.168.174.147:2379   pd            192.168.174.147  2379/2380                        linux/x86_64  Up|UI   /tidb-data/pd-2379            /tidb-deploy/pd-2379
192.168.174.145:9090   prometheus    192.168.174.145  9090/12020                       linux/x86_64  Up      /tidb-data/prometheus-9090    /tidb-deploy/prometheus-9090
192.168.174.145:4000   tidb          192.168.174.145  4000/10080                       linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
192.168.174.146:4000   tidb          192.168.174.146  4000/10080                       linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
192.168.174.147:4000   tidb          192.168.174.147  4000/10080                       linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
192.168.174.145:9000   tiflash       192.168.174.145  9000/3930/20170/20292/8234/8123  linux/x86_64  Up      /tidb-data/tiflash-9000       /tidb-deploy/tiflash-9000
192.168.174.146:9000   tiflash       192.168.174.146  9000/3930/20170/20292/8234/8123  linux/x86_64  Up      /tidb-data/tiflash-9000       /tidb-deploy/tiflash-9000
192.168.174.147:9000   tiflash       192.168.174.147  9000/3930/20170/20292/8234/8123  linux/x86_64  Up      /tidb-data/tiflash-9000       /tidb-deploy/tiflash-9000
192.168.174.145:20160  tikv          192.168.174.145  20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
192.168.174.146:20160  tikv          192.168.174.146  20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
192.168.174.147:20160  tikv          192.168.174.147  20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
Total nodes: 18

缩容 TiCDC 节点

下线 TiCDC 节点

tiup cluster scale-in tidb-test --node 192.168.174.147:8300

查看集群状态

tiup cluster display tidb-test

参考文档

https://docs.pingcap.com/zh/tidb/stable/scale-tidb-using-tiup/

posted @ 2025-05-21 08:54  小吉猫  阅读(36)  评论(0)    收藏  举报