1.检查 placement-rules的情况
[tidb@mysql1 ~]$ pd-ctl -i -u http://192.168.1.11:2379
» config show
{
"replication": {
"enable-placement-rules": "true",
"isolation-level": "",
"location-labels": "host",
"max-replicas": 3,
"strictly-match-label": "false"
},
"schedule": {
"enable-cross-table-merge": "true",
"enable-debug-metrics": "false",
"enable-joint-consensus": "true",
"enable-location-replacement": "true",
"enable-make-up-replica": "true",
"enable-one-way-merge": "false",
"enable-remove-down-replica": "true",
"enable-remove-extra-replica": "true",
"enable-replace-offline-replica": "true",
"high-space-ratio": 0.7,
"hot-region-cache-hits-threshold": 3,
"hot-region-schedule-limit": 4,
"leader-schedule-limit": 4,
"leader-schedule-policy": "count",
"low-space-ratio": 0.8,
"max-merge-region-keys": 200000,
"max-merge-region-size": 20,
"max-pending-peer-count": 16,
"max-snapshot-count": 3,
"max-store-down-time": "30m0s",
"merge-schedule-limit": 8,
"patrol-region-interval": "100ms",
"region-schedule-limit": 2048,
"region-score-formula-version": "v2",
"replica-schedule-limit": 64,
"scheduler-max-waiting-operator": 5,
"split-merge-interval": "1h0m0s",
"store-limit-mode": "manual",
"tolerant-size-ratio": 0
}
}
2.检查现有的 cdc_server
--只有11上有CDC 服务。
--tiflash也只有一个节点。
[tidb@mysql1 ~]$ ps -ef |grep cdc
tidb 96609 1 0 16:56 ? 00:00:07 bin/cdc server --addr 0.0.0.0:8300 --advertise-addr 192.168.1.11:8300 --pd http://192.168.1.11:2379,http://192.168.1.12:2379,http://192.168.1.13:2379 --data-dir=/tidb/tidb-data/cdc-8300 --config conf/cdc.toml --log-file /tidb/tidb-deploy/cdc-8300/log/cdc.log
tidb 102208 44178 0 17:20 pts/1 00:00:00 grep --color=auto cdc
mysql> select * from information_schema.cluster_info;
+---------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+-----------+
| TYPE | INSTANCE | STATUS_ADDRESS | VERSION | GIT_HASH | START_TIME | UPTIME | SERVER_ID |
+---------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+-----------+
| tidb | 192.168.1.12:4001 | 192.168.1.12:10081 | 5.1.1 | 797bddd25310ed42f0791c8eccb78be8cce2f502 | 2024-08-16T16:56:36+08:00 | 24m5.135387578s | 0 |
| tidb | 192.168.1.13:4000 | 192.168.1.13:10080 | 5.1.1 | 797bddd25310ed42f0791c8eccb78be8cce2f502 | 2024-08-16T16:56:36+08:00 | 24m5.135393558s | 0 |
| tidb | 192.168.1.11:4000 | 192.168.1.11:10080 | 5.1.1 | 797bddd25310ed42f0791c8eccb78be8cce2f502 | 2024-08-16T16:56:36+08:00 | 24m5.135396331s | 0 |
| pd | 192.168.1.13:2379 | 192.168.1.13:2379 | 5.1.1 | 7cba1912b317a533e18b16ea2ba9a14ed2891129 | 2024-08-16T16:56:27+08:00 | 24m14.135397738s | 0 |
| pd | 192.168.1.11:2379 | 192.168.1.11:2379 | 5.1.1 | 7cba1912b317a533e18b16ea2ba9a14ed2891129 | 2024-08-16T16:56:26+08:00 | 24m15.135399086s | 0 |
| pd | 192.168.1.12:2379 | 192.168.1.12:2379 | 5.1.1 | 7cba1912b317a533e18b16ea2ba9a14ed2891129 | 2024-08-16T16:56:27+08:00 | 24m14.135400418s | 0 |
| tiflash | 192.168.1.11:3930 | 192.168.1.11:20292 | v5.1.1 | c8fabfb50fe28db17cc5118133a69be255c40efd | 2024-08-16T16:56:40+08:00 | 24m1.135401766s | 0 |
| tikv | 192.168.1.12:20161 | 192.168.1.12:20181 | 5.1.1 | 4705d7c6e9c42d129d3309e05911ec6b08a25a38 | 2024-08-16T16:56:28+08:00 | 24m13.135403126s | 0 |
| tikv | 192.168.1.13:20160 | 192.168.1.13:20180 | 5.1.1 | 4705d7c6e9c42d129d3309e05911ec6b08a25a38 | 2024-08-16T16:56:29+08:00 | 24m12.135404509s | 0 |
| tikv | 192.168.1.11:20160 | 192.168.1.11:20180 | 5.1.1 | 4705d7c6e9c42d129d3309e05911ec6b08a25a38 | 2024-08-16T16:56:29+08:00 | 24m12.135405831s | 0 |
+---------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+-----------+
10 rows in set (0.02 sec)
3.新增节点
--扩容 CDC 和 tiflash 服务。
tiflash新增一个节点:12
cdc_server 新增一个节点:12
[tidb@mysql1 ~]$ cat config-scale-out.yaml
tiflash_servers:
- host: 192.168.1.14
cdc_servers:
- host: 192.168.1.12
--正式扩容
[tidb@mysql1 ~]$ tiup cluster scale-out tidbcluster config-scale-out.yaml --user root -p
Starting component `cluster`: /home/tidb/.tiup/components/cluster/v1.5.3/tiup-cluster scale-out tidbcluster config-scale-out.yaml --user root -p
Please confirm your topology:
Cluster type: tidb
Cluster name: tidbcluster
Cluster version: v5.1.1
Role Host Ports OS/Arch Directories
---- ---- ----- ------- -----------
tiflash 192.168.1.14 9000/8123/3930/20170/20292/8234 linux/x86_64 /tidb/tidb-deploy/tiflash-9000,/tidb/tidb-data/tiflash-9000
cdc 192.168.1.12 8300 linux/x86_64 /tidb/tidb-deploy/cdc-8300,/tidb/tidb-data/cdc-8300
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
Input SSH password:
+ [ 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
- Download tiflash:v5.1.1 (linux/amd64) ... Done
+ [ Serial ] - RootSSH: user=root, host=192.168.1.14, port=22
+ [ Serial ] - EnvInit: user=tidb, host=192.168.1.14
+ [ Serial ] - Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy','/tidb/tidb-data'
+ [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
+ [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.11
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.11
+ [ Serial ] - UserSSH: user=tidb, host=192.168.1.14
+ [ Serial ] - Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/tiflash-9000','/tidb/tidb-deploy/tiflash-9000/bin','/tidb/tidb-deploy/tiflash-9000/conf','/tidb/tidb-deploy/tiflash-9000/scripts'
+ [ Serial ] - UserSSH: user=tidb, host=192.168.1.12
+ [ Serial ] - Mkdir: host=192.168.1.12, directories='/tidb/tidb-deploy/cdc-8300','/tidb/tidb-deploy/cdc-8300/bin','/tidb/tidb-deploy/cdc-8300/conf','/tidb/tidb-deploy/cdc-8300/scripts'
- Copy blackbox_exporter -> 192.168.1.14 ... ⠇ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log','/t...
- Copy blackbox_exporter -> 192.168.1.14 ... ⠙ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log','/t...
- Copy blackbox_exporter -> 192.168.1.14 ... ⠧ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log','/t...
- Copy node_exporter -> 192.168.1.14 ... ⠦ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log','/tidb/...
- Copy blackbox_exporter -> 192.168.1.14 ... ⠸ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log','/t...
+ [ Serial ] - ScaleConfig: cluster=tidbcluster, user=tidb, host=192.168.1.12, service=cdc-8300.service, deploy_dir=/tidb/tidb-deploy/cdc-8300, data_dir=[/tidb/tidb-data/cdc-8300], log_dir=/tidb
- Copy blackbox_exporter -> 192.168.1.14 ... ⠙ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log','/t...
- Copy blackbox_exporter -> 192.168.1.14 ... ⠦ Mkdir: host=192.168.1.14, directories='/tidb/tidb-deploy/monitor-9100','/tidb/tidb-data/monitor-9100','/tidb/tidb-deploy/monitor-9100/log',''/t...
- Copy node_exporter -> 192.168.1.14 ... Done
+ [ Serial ] - ScaleConfig: cluster=tidbcluster, user=tidb, host=192.168.1.14, service=tiflash-9000.service, deploy_dir=/tidb/tidb-deploy/tiflash-9000, data_dir=[/tidb/tidb-data/tiflash-9000], log_dir=/tidb/tidb-deploy/tiflash-9000/log, cache_dir=
+ Check status
Enabling component tiflash
Enabling instance 192.168.1.14:9000
Enable instance 192.168.1.14:9000 success
Enabling component cdc
Enabling instance 192.168.1.12:8300
Enable instance 192.168.1.12:8300 success
Enabling component node_exporter
Enabling instance 192.168.1.12
Enabling instance 192.168.1.14
Enable 192.168.1.14 success
Enable 192.168.1.12 success
Enabling component blackbox_exporter
Enabling instance 192.168.1.12
Enabling instance 192.168.1.14
Enable 192.168.1.14 success
Enable 192.168.1.12 success
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.12
+ [Parallel] - UserSSH: user=tidb, host=192.168.1.14
+ [ Serial ] - Save meta
+ [ Serial ] - StartCluster
Starting component tiflash
Starting instance 192.168.1.14:9000
Start instance 192.168.1.14:9000 success
Starting component cdc
Starting instance 192.168.1.12:8300
Start instance 192.168.1.12:8300 success
Starting component node_exporter
Starting instance 192.168.1.12
Starting instance 192.168.1.14
Start 192.168.1.12 success
Start 192.168.1.14 success
Starting component blackbox_exporter
Starting instance 192.168.1.12
Starting instance 192.168.1.14
Start 192.168.1.12 success
Start 192.168.1.14 success
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tispark-worker-7078.service, deploy_dir=/tidb/tidb-deploy/tispark-worker-7078, data_dir=[], log_dir=/tidb/tidb-deploy/tispark-worker-7078/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/pd-2379.service, deploy_dir=/tidb/tidb-deploy/pd-2379, data_dir=[/tidb/tidb-data/pd-2379], log_dir=/tidb/tidb-deploy/pd-2379/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.12, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/pd-2379.service, deploy_dir=/tidb/tidb-deploy/pd-2379, data_dir=[/tidb/tidb-data/pd-2379], log_dir=/tidb/tidb-deploy/pd-2379/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.13, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/pd-2379.service, deploy_dir=/tidb/tidb-deploy/pd-2379, data_dir=[/tidb/tidb-data/pd-2379], log_dir=/tidb/tidb-deploy/pd-2379/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tikv-20160.service, deploy_dir=/tidb/tidb-deploy/tikv-20160, data_dir=[/tidb/tidb-data/tikv-20160], log_dir=/tidb/tidb-deploy/tikv-20160/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.12, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tikv-20161.service, deploy_dir=/tidb/tidb-deploy/tikv-20161, data_dir=[/tidb/tidb-data/tikv-20161], log_dir=/tidb/tidb-deploy/tikv-20161/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.13, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tikv-20160.service, deploy_dir=/tidb/tidb-deploy/tikv-20160, data_dir=[/tidb/tidb-data/tikv-20160], log_dir=/tidb/tidb-deploy/tikv-20160/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tidb-4000.service, deploy_dir=/tidb/tidb-deploy/tidb-4000, data_dir=[], log_dir=/tidb/tidb-deploy/tidb-4000/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.12, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tidb-4001.service, deploy_dir=/tidb/tidb-deploy/tidb-4001, data_dir=[], log_dir=/tidb/tidb-deploy/tidb-4001/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.13, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tidb-4000.service, deploy_dir=/tidb/tidb-deploy/tidb-4000, data_dir=[], log_dir=/tidb/tidb-deploy/tidb-4000/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tiflash-9000.service, deploy_dir=/tidb/tidb-deploy/tiflash-9000, data_dir=[/tidb/tidb-data/tiflash-9000], log_dir=/tidb/tidb-deploy/tiflash-9000/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.14, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tiflash-9000.service, deploy_dir=/tidb/tidb-deploy/tiflash-9000, data_dir=[/tidb/tidb-data/tiflash-9000], log_dir=/tidb/tidb-deploy/tiflash-9000/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/cdc-8300.service, deploy_dir=/tidb/tidb-deploy/cdc-8300, data_dir=[/tidb/tidb-data/cdc-8300], log_dir=/tidb/tidb-deploy/cdc-8300/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.12, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/cdc-8300.service, deploy_dir=/tidb/tidb-deploy/cdc-8300, data_dir=[/tidb/tidb-data/cdc-8300], log_dir=/tidb/tidb-deploy/cdc-8300/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/prometheus-9090.service, deploy_dir=/tidb/tidb-deploy/prometheus-9090, data_dir=[/tidb/tidb-data/prometheus-9090], log_dir=/tidb/tidb-deploy/prometheus-9090/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/grafana-3000.service, deploy_dir=/tidb/tidb-deploy/grafana-3000, data_dir=[], log_dir=/tidb/tidb-deploy/grafana-3000/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/alertmanager-9093.service, deploy_dir=/tidb/tidb-deploy/alertmanager-9093, data_dir=[/tidb/tidb-data/alertmanager-9093], log_dir=/tidb/tidb-deploy/alertmanager-9093/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - InitConfig: cluster=tidbcluster, user=tidb, host=192.168.1.11, path=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache/tispark-master-7077.service, deploy_dir=/tidb/tidb-deploy/tispark-master-7077, data_dir=[], log_dir=/tidb/tidb-deploy/tispark-master-7077/log, cache_dir=/home/tidb/.tiup/storage/cluster/clusters/tidbcluster/config-cache
+ [ Serial ] - SystemCtl: host=192.168.1.11 action=reload prometheus-9090.service
+ [ Serial ] - UpdateTopology: cluster=tidbcluster
Scaled cluster `tidbcluster` out successfully
4.cdc 检查
--果然2号节点新怎了CDC ;
[root@mysql2 tidb-deploy]# ps -ef |grep cdc
tidb 124736 1 0 17:23 ? 00:00:01 bin/cdc server --addr 0.0.0.0:8300 --advertise-addr 192.168.1.12:8300 --pd http://192.168.1.11:2379,http://192.168.1.12:2379,http://192.168.1.13:2379 --data-dir=/tidb/tidb-data/cdc-8300 --config conf/cdc.toml --log-file /tidb/tidb-deploy/cdc-8300/log/cdc.log
root 125984 1766 0 17:26 pts/0 00:00:00 grep --color=auto cdc
--1号节点原先有一个,说明扩容成功。
[tidb@mysql1 ~]$ ps -ef |grep cdc
tidb 96609 1 0 16:56 ? 00:00:10 bin/cdc server --addr 0.0.0.0:8300 --advertise-addr 192.168.1.11:8300 --pd http://192.168.1.11:2379,http://192.168.1.12:2379,http://192.168.1.13:2379 --data-dir=/tidb/tidb-data/cdc-8300 --config conf/cdc.toml --log-file /tidb/tidb-deploy/cdc-8300/log/cdc.log
tidb 106266 105488 0 17:27 pts/2 00:00:00 grep --color=auto cdc
[tidb@mysql1 ~]$
--tiflash检查
mysql> select * from information_schema.cluster_info;
+---------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+-----------+
| TYPE | INSTANCE | STATUS_ADDRESS | VERSION | GIT_HASH | START_TIME | UPTIME | SERVER_ID |
+---------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+-----------+
| tidb | 192.168.1.12:4001 | 192.168.1.12:10081 | 5.1.1 | 797bddd25310ed42f0791c8eccb78be8cce2f502 | 2024-08-16T16:56:36+08:00 | 31m50.850401814s | 0 |
| tidb | 192.168.1.13:4000 | 192.168.1.13:10080 | 5.1.1 | 797bddd25310ed42f0791c8eccb78be8cce2f502 | 2024-08-16T16:56:36+08:00 | 31m50.850407862s | 0 |
| tidb | 192.168.1.11:4000 | 192.168.1.11:10080 | 5.1.1 | 797bddd25310ed42f0791c8eccb78be8cce2f502 | 2024-08-16T16:56:36+08:00 | 31m50.850409404s | 0 |
| pd | 192.168.1.13:2379 | 192.168.1.13:2379 | 5.1.1 | 7cba1912b317a533e18b16ea2ba9a14ed2891129 | 2024-08-16T16:56:27+08:00 | 31m59.850410857s | 0 |
| pd | 192.168.1.11:2379 | 192.168.1.11:2379 | 5.1.1 | 7cba1912b317a533e18b16ea2ba9a14ed2891129 | 2024-08-16T16:56:26+08:00 | 32m0.850412319s | 0 |
| pd | 192.168.1.12:2379 | 192.168.1.12:2379 | 5.1.1 | 7cba1912b317a533e18b16ea2ba9a14ed2891129 | 2024-08-16T16:56:27+08:00 | 31m59.850414902s | 0 |
| tikv | 192.168.1.12:20161 | 192.168.1.12:20181 | 5.1.1 | 4705d7c6e9c42d129d3309e05911ec6b08a25a38 | 2024-08-16T16:56:28+08:00 | 31m58.850416221s | 0 |
| tikv | 192.168.1.13:20160 | 192.168.1.13:20180 | 5.1.1 | 4705d7c6e9c42d129d3309e05911ec6b08a25a38 | 2024-08-16T16:56:29+08:00 | 31m57.850417525s | 0 |
| tikv | 192.168.1.11:20160 | 192.168.1.11:20180 | 5.1.1 | 4705d7c6e9c42d129d3309e05911ec6b08a25a38 | 2024-08-16T16:56:29+08:00 | 31m57.850418882s | 0 |
| tiflash | 192.168.1.11:3930 | 192.168.1.11:20292 | v5.1.1 | c8fabfb50fe28db17cc5118133a69be255c40efd | 2024-08-16T16:56:40+08:00 | 31m46.850423342s | 0 |
| tiflash | 192.168.1.14:3930 | 192.168.1.14:20292 | v5.1.1 | c8fabfb50fe28db17cc5118133a69be255c40efd | 2024-08-16T17:23:13+08:00 | 5m13.850424725s | 0 |
+---------+--------------------+--------------------+---------+------------------------------------------+---------------------------+------------------+-----------+
11 rows in set (0.01 sec)
5.tiflash 的使用
create table my_test2(id int,name varchar(20));
insert into my_test2 values(1,'薛双奇1');
insert into my_test2 values(2,'薛双奇2');
insert into my_test2 values(3,'薛双奇3');
insert into my_test2 values(4,'薛双奇4');
insert into my_test2 values(5,'薛双奇5');
insert into my_test2 values(6,'薛双奇6');
insert into my_test2 values(7,'薛双奇7');
insert into my_test2 values(8,'薛双奇8');
insert into my_test2 values(9,'薛双奇9');
insert into my_test2 values(10,'薛双奇10');
select * from my_test2;
mysql> select * from my_test2;
+------+-------------+
| id | name |
+------+-------------+
| 1 | 薛双奇1 |
| 2 | 薛双奇2 |
| 3 | 薛双奇3 |
| 4 | 薛双奇4 |
| 5 | 薛双奇5 |
| 6 | 薛双奇6 |
| 7 | 薛双奇7 |
| 8 | 薛双奇8 |
| 9 | 薛双奇9 |
| 10 | 薛双奇10 |
+------+-------------+
10 rows in set (0.00 sec)
--创建2个副本
ALTER TABLE my_test2 SET TIFLASH REPLICA 2;
mysql> ALTER TABLE my_test2 SET TIFLASH REPLICA 2;
Query OK, 0 rows affected (0.52 sec)
SELECT * FROM information_schema.tiflash_replica
WHERE TABLE_SCHEMA = 'test'
and TABLE_NAME = 'my_test2';
mysql> SELECT * FROM information_schema.tiflash_replica
-> WHERE TABLE_SCHEMA = 'test'
-> and TABLE_NAME = 'my_test2';
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_ID | REPLICA_COUNT | LOCATION_LABELS | AVAILABLE | PROGRESS |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| test | my_test2 | 55 | 2 | | 1 | 1 |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
1 row in set (0.00 sec)
--查询执行计划 。
mysql> desc select count(*) from test.my_test2;
+----------------------------+---------+-------------------+----------------+---------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+---------+-------------------+----------------+---------------------------------+
| StreamAgg_25 | 1.00 | root | | funcs:count(Column#7)->Column#4 |
| └─TableReader_26 | 1.00 | root | | data:StreamAgg_9 |
| └─StreamAgg_9 | 1.00 | batchCop[tiflash] | | funcs:count(1)->Column#7 |
| └─TableFullScan_24 | 10.00 | batchCop[tiflash] | table:my_test2 | keep order:false, stats:pseudo |
+----------------------------+---------+-------------------+----------------+---------------------------------+
4 rows in set (0.00 sec)