TIDB 数据库集群部署(3)

# node_exporter and blackbox_exporter servers
[monitored_servers]
172.16.5.50
172.16.5.51
172.16.5.52
172.16.5.53
    ----------------------end-------------------
# 拓扑结构如下
Name HostIP Services
tidb-tikv1 172.16.5.50 PD1, TiDB1, TiKV1
tidb-tikv2 172.16.5.51 PD2, TiKV2
tidb-tikv3 172.16.5.52 PD3, TiKV3
tidb-tikv4 172.16.5.53 TiDB2
# 初始化新增节点
ansible-playbook bootstrap.yml -l 172.16.5.53
# 部署新增节点
ansible-playbook deploy.yml -l 172.16.5.53
# 启动新节点服务
ansible-playbook start.yml -l 172.16.5.53
# 更新 Prometheus 配置并重启
ansible-playbook rolling_update_monitor.yml --tags=prometheus

3.2、扩容PD节点

# 拓扑结构如下# 单机Tikv实例
Name HostIP Services
tidb-tikv1 172.16.5.50 PD1, TiDB1, TiKV1
tidb-tikv2 172.16.5.51 PD2, TiKV2
tidb-tikv3 172.16.5.52 PD3, TiKV3
# 新增一台PD节点
添加一个 PD 节点(tidb-pd1),IP 地址为 172.16.5.54
# 编辑inventory.ini 文件
cd /home/tidb/tidb-ansible
vim inventory.ini
## TiDB Cluster Part
[tidb_servers]
172.16.5.50
172.16.5.51

[tikv_servers]
172.16.5.50
172.16.5.51
172.16.5.52

[pd_servers]
172.16.5.50
172.16.5.51
172.16.5.52
172.16.5.54

## Monitoring Part
# prometheus and pushgateway servers
[monitoring_servers]
172.16.5.50

# node_exporter and blackbox_exporter servers
[monitored_servers]
172.16.5.50
172.16.5.51
172.16.5.52
172.16.5.54
# 拓扑结构如下
Name HostIP Services
tidb-tikv1 172.16.5.50 PD1, TiDB1, TiKV1
tidb-tikv2 172.16.5.51 PD2, TiKV2
tidb-tikv3 172.16.5.52 PD3, TiKV3
tidb-pd1 172.16.5.54 PD4
# 初始化新增节点
ansible-playbook bootstrap.yml -l 172.16.5.54
# 部署新增节点
ansible-playbook deploy.yml -l 172.16.5.54
# 登录新增的 PD 节点,编辑启动脚本:{deploy_dir}/scripts/run_pd.sh
1、移除 --initial-cluster="xxxx" \ 配置。
2、添加 --join="http://172.16.10.1:2379" \,IP 地址 (172.16.10.1) 可以是集群内现有 PD IP 地址中的任意一个。
3、在新增 PD 节点中手动启动 PD 服务:
{deploy_dir}/scripts/start_pd.sh
4、使用 pd-ctl 检查新节点是否添加成功:
/home/tidb/tidb-ansible/resources/bin/pd-ctl -u "http://172.16.10.1:2379" -d member
# 滚动升级整个集群
ansible-playbook rolling_update.yml
# 更新 Prometheus 配置并重启
ansible-playbook rolling_update_monitor.yml --tags=prometheus

四、tidb集群测试

4.1、sysbench基准库测试

sysbench安装

1 # 二进制安装
2 curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
3 sudo yum -y install sysbench

性能测试

# cpu性能测试
sysbench --test=cpu --cpu-max-prime=20000 run
----------------------------------start----------------------------------------
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 20000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 286.71
General statistics:
total time: 10.0004s
total number of events: 2868
Latency (ms):
min: 3.46
avg: 3.49
max: 4.49
95th percentile: 3.55
sum: 9997.23
Threads fairness:
events (avg/stddev): 2868.0000/0.00
execution time (avg/stddev): 9.9972/0.00
-----------------------------------end-------------------------------------------
# 线程测试
sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run
------------------------------------start-----------------------------------------
Number of threads: 64
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.0048s
total number of events: 108883
Latency (ms):
min: 0.05
avg: 5.88
max: 49.15
95th percentile: 17.32
sum: 640073.32
Threads fairness:
events (avg/stddev): 1701.2969/36.36
execution time (avg/stddev): 10.0011/0.00
-----------------------------------end-----------------------------------------
# 磁盘IO测试
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
----------------------------------start-----------------------------------------
128 files, 24576Kb each, 3072Mb total
Creating files for the test...
Extra file open flags: (none)
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
Creating file test_file.4
Creating file test_file.5
Creating file test_file.6
Creating file test_file.7
Creating file test_file.8
Creating file test_file.9
Creating file test_file.10
Creating file test_file.11
Creating file test_file.12
Creating file test_file.13
Creating file test_file.14
Creating file test_file.15
Creating file test_file.16
Creating file test_file.17
Creating file test_file.18
Creating file test_file.19
Creating file test_file.20
Creating file test_file.21
Creating file test_file.22
Creating file test_file.23
Creating file test_file.24
Creating file test_file.25
Creating file test_file.26
Creating file test_file.27
Creating file test_file.28
Creating file test_file.29
Creating file test_file.30
Creating file test_file.31
Creating file test_file.32
Creating file test_file.33
Creating file test_file.34
Creating file test_file.35
Creating file test_file.36
Creating file test_file.37
Creating file test_file.38
Creating file test_file.39
Creating file test_file.40
Creating file test_file.41
Creating file test_file.42
Creating file test_file.43
Creating file test_file.44
Creating file test_file.45
Creating file test_file.46
Creating file test_file.47
Creating file test_file.48
Creating file test_file.49
Creating file test_file.50
Creating file test_file.51
Creating file test_file.52
Creating file test_file.53
Creating file test_file.54
Creating file test_file.55
Creating file test_file.56
Creating file test_file.57
Creating file test_file.58
Creating file test_file.59
Creating file test_file.60
Creating file test_file.61
Creating file test_file.62
Creating file test_file.63
Creating file test_file.64
Creating file test_file.65
Creating file test_file.66
Creating file test_file.67
Creating file test_file.68
Creating file test_file.69
Creating file test_file.70
Creating file test_file.71
Creating file test_file.72
Creating file test_file.73
Creating file test_file.74
Creating file test_file.75
Creating file test_file.76
Creating file test_file.77
Creating file test_file.78
Creating file test_file.79
Creating file test_file.80
Creating file test_file.81
Creating file test_file.82
Creating file test_file.83
Creating file test_file.84
Creating file test_file.85
Creating file test_file.86
Creating file test_file.87
Creating file test_file.88
Creating file test_file.89
Creating file test_file.90
Creating file test_file.91
Creating file test_file.92
Creating file test_file.93
Creating file test_file.94
Creating file test_file.95
Creating file test_file.96
Creating file test_file.97
Creating file test_file.98
Creating file test_file.99
Creating file test_file.100
Creating file test_file.101
Creating file test_file.102
Creating file test_file.103
Creating file test_file.104
Creating file test_file.105
Creating file test_file.106
Creating file test_file.107
Creating file test_file.108
Creating file test_file.109
Creating file test_file.110
Creating file test_file.111
Creating file test_file.112
Creating file test_file.113
Creating file test_file.114
Creating file test_file.115
Creating file test_file.116
Creating file test_file.117
Creating file test_file.118
Creating file test_file.119
Creating file test_file.120
Creating file test_file.121
Creating file test_file.122
Creating file test_file.123
Creating file test_file.124
Creating file test_file.125
Creating file test_file.126
Creating file test_file.127
3221225472 bytes written in 339.76 seconds (9.04 MiB/sec)
----------------------------------end------------------------------------------
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
----------------------------------start-----------------------------------------
Number of threads: 16
Initializing random number generator from current time
Extra file open flags: (none)
128 files, 24MiB each
3GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...
Threads started!
File operations:
reads/s: 299.19
writes/s: 199.46
fsyncs/s: 816.03
Throughput:
read, MiB/s: 4.67
written, MiB/s: 3.12
General statistics:
total time: 10.8270s
total number of events: 12189
Latency (ms):
min: 0.00
avg: 13.14
max: 340.58
95th percentile: 92.42
sum: 160186.15
Threads fairness:
events (avg/stddev): 761.8125/216.01
execution time (avg/stddev): 10.0116/0.01
--------------------------------------end---------------------------------------
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup
# 内存测试
sysbench --test=memory --memory-block-size=8k --memory-total-size=4G run
------------------------------------start-----------------------------------------
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 8KiB
total size: 4096MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 524288 (1111310.93 per second)
4096.00 MiB transferred (8682.12 MiB/sec)
General statistics:
total time: 0.4692s
total number of events: 524288
Latency (ms):
min: 0.00
avg: 0.00
max: 0.03
95th percentile: 0.00
sum: 381.39

Threads fairness:
events (avg/stddev): 524288.0000/0.00
execution time (avg/stddev): 0.3814/0.00
-------------------------------------end---------------------------------------

4.2、OLTP测试

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/33c955f0f0a426c0d940d222a00b9e51.html