【TIDB】同时扩容PD/TIDB/TIKV

1.准备配置文件 

--PD/TIDB/TIKV 各增加一个节点。
vi config-scale-out.yaml
tidb_servers:
	- host: 192.168.1.14
pd_servers:
	- host: 192.168.1.14
tikv_servers:
	- host: 192.168.1.14

2.扩容前检查 

mysql> select * from information_schema.cluster_info; 
+------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+
| TYPE | INSTANCE           | STATUS_ADDRESS     | VERSION | GIT_HASH                                 | START_TIME                | UPTIME           |
+------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+
| tidb | 192.168.1.11:4000  | 192.168.1.11:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:03:56+08:00 | 17m22.15787377s  |
| tidb | 192.168.1.12:4000  | 192.168.1.12:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:03:56+08:00 | 17m22.157879419s |
| tidb | 192.168.1.13:4000  | 192.168.1.13:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:03:56+08:00 | 17m22.157880749s |
| pd   | 192.168.1.13:2379  | 192.168.1.13:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:03:48+08:00 | 17m30.157907704s |
| pd   | 192.168.1.11:2379  | 192.168.1.11:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:03:48+08:00 | 17m30.157909126s |
| pd   | 192.168.1.12:2379  | 192.168.1.12:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:03:48+08:00 | 17m30.157910312s |
| tikv | 192.168.1.13:20160 | 192.168.1.13:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:03:50+08:00 | 17m28.157911547s |
| tikv | 192.168.1.11:20160 | 192.168.1.11:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:03:50+08:00 | 17m28.157913377s |
| tikv | 192.168.1.12:20160 | 192.168.1.12:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:03:50+08:00 | 17m28.157914608s |
+------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+
9 rows in set (0.01 sec)

3.执行扩容 

[tidb@mysql1 ~]$ tiup cluster scale-out tidbcluster config-scale-out.yaml --user root -p
Input SSH password: 

+ Detect CPU Arch Name
  - Detecting node 192.168.1.14 Arch info ... Done

+ Detect CPU OS Name
  - Detecting node 192.168.1.14 OS info ... Done
Please confirm your topology:
Cluster type:    tidb
Cluster name:    tidbcluster
Cluster version: v4.0.7
Role  Host          Ports        OS/Arch       Directories
----  ----          -----        -------       -----------
pd    192.168.1.14  2379/2380    linux/x86_64  /tidb/tidb-deploy/pd-2379,/tidb/tidb-data/pd-2379
tikv  192.168.1.14  20160/20180  linux/x86_64  /tidb/tidb-deploy/tikv-20160,/tidb/tidb-data/tikv-20160
tidb  192.168.1.14  4000/10080   linux/x86_64  /tidb/tidb-deploy/tidb-4000
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=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/ssh/id_rsa, publicKey=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.12
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.13
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.12
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.13
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.12
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.13
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ Download TiDB components
  - Download pd:v4.0.7 (linux/amd64) ... Done
  - Download tikv:v4.0.7 (linux/amd64) ... Done
  - Download tidb:v4.0.7 (linux/amd64) ... Done
  - Download node_exporter: (linux/amd64) ... Done
  - Download blackbox_exporter: (linux/amd64) ... Done
+ Initialize target host environments
  - Initialized host 192.168.1.14  ... Done
+ Deploy TiDB instance
  - Deploy instance pd -> 192.168.1.14:2379 ... Done
  - Deploy instance tikv -> 192.168.1.14:20160 ... Done
  - Deploy instance tidb -> 192.168.1.14:4000 ... Done
  - Deploy node_exporter -> 192.168.1.14 ... Done
  - Deploy blackbox_exporter -> 192.168.1.14 ... Done
+ Copy certificate to remote host
+ Generate scale-out config
  - Generate scale-out config pd -> 192.168.1.14:2379 ... Done
  - Generate scale-out config tikv -> 192.168.1.14:20160 ... Done
  - Generate scale-out config tidb -> 192.168.1.14:4000 ... Done
+ Init monitor config
  - Generate config node_exporter -> 192.168.1.14 ... Done
  - Generate config blackbox_exporter -> 192.168.1.14 ... Done
Enabling component pd
	Enabling instance 192.168.1.14:2379
	Enable instance 192.168.1.14:2379 success
Enabling component tikv
	Enabling instance 192.168.1.14:20160
	Enable instance 192.168.1.14:20160 success
Enabling component tidb
	Enabling instance 192.168.1.14:4000
	Enable instance 192.168.1.14:4000 success
Enabling component node_exporter
	Enabling instance 192.168.1.14
	Enable 192.168.1.14 success
Enabling component blackbox_exporter
	Enabling instance 192.168.1.14
	Enable 192.168.1.14 success
+ [ Serial ] - Save meta
+ [ Serial ] - Start new instances
Starting component pd
	Starting instance 192.168.1.14:2379
	Start instance 192.168.1.14:2379 success
Starting component tikv
	Starting instance 192.168.1.14:20160
	Start instance 192.168.1.14:20160 success
Starting component tidb
	Starting instance 192.168.1.14:4000
	Start instance 192.168.1.14:4000 success
Starting component node_exporter
	Starting instance 192.168.1.14
	Start 192.168.1.14 success
Starting component blackbox_exporter
	Starting instance 192.168.1.14
	Start 192.168.1.14 success
+ Refresh components conifgs
  - Generate config pd -> 192.168.1.11:2379 ... Done
  - Generate config pd -> 192.168.1.12:2379 ... Done
  - Generate config pd -> 192.168.1.13:2379 ... Done
  - Generate config pd -> 192.168.1.14:2379 ... Done
  - Generate config tikv -> 192.168.1.11:20160 ... Done
  - Generate config tikv -> 192.168.1.12:20160 ... Done
  - Generate config tikv -> 192.168.1.13:20160 ... Done
  - Generate config tikv -> 192.168.1.14:20160 ... Done
  - Generate config tidb -> 192.168.1.11:4000 ... Done
  - Generate config tidb -> 192.168.1.12:4000 ... Done
  - Generate config tidb -> 192.168.1.13:4000 ... Done
  - Generate config tidb -> 192.168.1.14:4000 ... Done
  - Generate config prometheus -> 192.168.1.11:9090 ... Done
  - Generate config grafana -> 192.168.1.11:3000 ... Done
  - Generate config alertmanager -> 192.168.1.11:9093 ... Done
+ Reload prometheus and grafana
  - Reload prometheus -> 192.168.1.11:9090 ... Done
  - Reload grafana -> 192.168.1.11:3000 ... Done
+ [ Serial ] - UpdateTopology: cluster=tidbcluster
Scaled cluster `tidbcluster` out successfully

4.扩容后检查

mysql> select * from information_schema.cluster_info;
+------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+
| TYPE | INSTANCE           | STATUS_ADDRESS     | VERSION | GIT_HASH                                 | START_TIME                | UPTIME           |
+------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+
| tidb | 192.168.1.13:4000  | 192.168.1.13:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:03:56+08:00 | 20m24.438042855s |
| tidb | 192.168.1.14:4000  | 192.168.1.14:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:23:06+08:00 | 1m14.438048582s  |
| tidb | 192.168.1.11:4000  | 192.168.1.11:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:03:56+08:00 | 20m24.438050469s |
| tidb | 192.168.1.12:4000  | 192.168.1.12:10080 | 4.0.7   | ed939f3f11599b5a38352c5c160c917df3ebf3eb | 2024-08-16T13:03:56+08:00 | 20m24.438051689s |
| pd   | 192.168.1.13:2379  | 192.168.1.13:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:03:48+08:00 | 20m32.438052829s |
| pd   | 192.168.1.14:2379  | 192.168.1.14:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:23:00+08:00 | 1m20.438054002s  |
| pd   | 192.168.1.11:2379  | 192.168.1.11:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:03:48+08:00 | 20m32.438055173s |
| pd   | 192.168.1.12:2379  | 192.168.1.12:2379  | 4.0.7   | 8b0348f545611d5955e32fdcf3c57a3f73657d77 | 2024-08-16T13:03:48+08:00 | 20m32.43805927s  |
| tikv | 192.168.1.13:20160 | 192.168.1.13:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:03:50+08:00 | 20m30.438060594s |
| tikv | 192.168.1.14:20160 | 192.168.1.14:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:23:04+08:00 | 1m16.438061762s  |
| tikv | 192.168.1.11:20160 | 192.168.1.11:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:03:50+08:00 | 20m30.438062906s |
| tikv | 192.168.1.12:20160 | 192.168.1.12:20180 | 4.0.7   | bc0a9b3974f32cc2e08244a6eaf5284e5e5f4d76 | 2024-08-16T13:03:50+08:00 | 20m30.438064144s |
+------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+
12 rows in set (0.01 sec)
--由此可见已经扩容成功。

5.数据验证 

mysql> select * from test.my_test1; 
+------+------------+
| id   | name       |
+------+------------+
|    1 | 薛双奇1    |
|    2 | 薛双奇2    |
+------+------------+
2 rows in set (0.03 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值