欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

TIDB数据集群部署

程序员文章站 2022-07-06 12:08:33
TIDB 数据库集群 一、TiDB数据介绍 1.1、TiDB数据简介 TiDB 是 PingCAP 公司设计的开源分布式 HTAP (Hybrid Transactional and Analytical Processing) 数据库,结合了传统的 RDBMS 和 NoSQL 的最佳特性。TiDB ......

 tidb 数据库集群

 一、tidb数据介绍

 1.1、tidb数据简介

tidb 是 pingcap 公司设计的开源分布式 htap (hybrid transactional and analytical processing) 数据库,结合了传统的 rdbms 和 nosql 的最佳特性。tidb 兼容 mysql,支持无限的水平扩展,具备强一致性和高可用性。tidb 的目标是为 oltp (online transactional processing) 和 olap (online analytical processing) 场景提供一站式的解决方案。

tidb 具备如下特性:

高度兼容 mysql

,无需修改代码即可从 mysql 轻松迁移至 tidb,分库分表后的 mysql 集群亦可通过 tidb 工具进行实时迁移。

水平弹性扩展

通过简单地增加新节点即可实现 tidb 的水平扩展,按需扩展吞吐或存储,轻松应对高并发、海量数据场景。

分布式事务

tidb 100% 支持标准的 acid 事务。

真正金融级高可用

相比于传统主从 (m-s) 复制方案,基于 raft 的多数派选举协议可以提供金融级的 100% 数据强一致性保证,且在不丢失大多数副本的前提下,可以实现故障的自动恢复 (auto-failover),无需人工介入。

一站式 htap 解决方案

tidb 作为典型的 oltp 行存数据库,同时兼具强大的 olap 性能,配合 tispark,可提供一站式 htap 解决方案,一份存储同时处理 oltp & olap,无需传统繁琐的 etl 过程。

云原生 sql 数据库

tidb 是为云而设计的数据库,支持公有云、私有云和混合云,使部署、配置和维护变得十分简单。

tidb server

tidb server 负责接收 sql 请求,处理 sql 相关的逻辑,并通过 pd 找到存储计算所需数据的 tikv 地址,与 tikv 交互获取数据,最终返回结果。tidb server 是无状态的,其本身并不存储数据,只负责计算,可以无限水平扩展,可以通过负载均衡组件(如lvs、haproxy 或 f5)对外提供统一的接入地址。

pd server

placement driver (简称 pd) 是整个集群的管理模块,其主要工作有三个:一是存储集群的元信息(某个 key 存储在哪个 tikv 节点);二是对 tikv 集群进行调度和负载均衡(如数据的迁移、raft group leader 的迁移等);三是分配全局唯一且递增的事务 id。

pd 是一个集群,需要部署奇数个节点,一般线上推荐至少部署 3 个节点

tikv server

tikv server 负责存储数据,从外部看 tikv 是一个分布式的提供事务的 key-value 存储引擎。存储数据的基本单位是 region,每个 region 负责存储一个 key range(从 startkey 到 endkey 的左闭右开区间)的数据,每个 tikv 节点会负责多个 region。tikv 使用 raft 协议做复制,保持数据的一致性和容灾。副本以 region 为单位进行管理,不同节点上的多个 region 构成一个 raft group,互为副本。数据在多个 tikv 之间的负载均衡由 pd 调度,这里也是以 region 为单位进行调度

tispark

tispark 作为 tidb 中解决用户复杂 olap 需求的主要组件,将 spark sql 直接运行在 tidb 存储层上,同时融合 tikv 分布式集群的优势,并融入大数据社区生态。至此,tidb 可以通过一套系统,同时支持 oltp 与 olap,免除用户数据同步的烦恼

1.2、tidb 数据基本操作

创建、查看和删除数据库

 1 create database db_name [options];
 2 create database if not exists samp_db;
 3 drop database samp_db;
 4 drop table if exists person;
 5 create index person_num on person (number);
 6 alter table person add index person_num (number);
 7 create unique index person_num on person (number);
 8 create user 'tiuser'@'localhost' identified by '123456';
 9 grant select on samp_db.* to 'tiuser'@'localhost';
10 show grants for tiuser@localhost;
11 drop user 'tiuser'@'localhost';
12 grant all privileges on test.* to 'xxxx'@'%' identified by 'yyyyy';
13 revoke all privileges on `test`.* from 'genius'@'localhost';
14 show grants for 'root'@'%';
15 select insert_priv from mysql.user where user='test' and host='%';
16 flush privileges;

二、tidb ansible 部署

 2.1、安装tidb集群基础环境

使用三台物理机搭建tidb集群,三台机器ip 为 172.16.5.50,172.16.5.51,172.16.5.10,其中172.16.5.51作为中控机。

软件安装如下:

172.16.5.51 tidb,pd,tikv

172.16.5.50 tikv

172.16.5.10 tikv

安装中控机软件

1  yum -y install epel-release git curl sshpass atop vim htop net-tools 
2  yum -y install python-pip

在中控机上创建 tidb 用户,并生成 ssh key

1 # 创建tidb用户
2 useradd -m -d /home/tidb tidb && passwd tidb
3 # 配置tidb用户sudo权限
4 visudo
5 tidb all=(all) nopasswd: all
6 # 使用tidb账户生成 ssh key
7 su tidb && ssh-keygen -t rsa -c mikel@tidb

在中控机器上下载 tidb-ansible

1 # 下载tidb-ansible 版本
cd /home/tidb && git clone -b release-2.0 https://github.com/pingcap/tidb-ansible.git 2 # 安装ansible及依赖 cd /home/tidb/tidb-ansible/ && pip install -r ./requirements.txt

在中控机上配置部署机器ssh互信及sudo 规则

 1 # 配置hosts.ini
 2 su tidb && cd /home/tidb/tidb-ansible
 3 vim hosts.ini
 4 [servers]
 5 172.16.5.50
 6 172.16.5.51
 7 172.16.5.52
 8 [all:vars]
 9 username = tidb
10 ntp_server = pool.ntp.org
11 # 配置ssh 互信
12 ansible-playbook -i hosts.ini create_users.yml -u root -k

在目标机器上安装ntp服务

1 # 中控机器上给目标主机安装ntp服务
2 cd /home/tidb/tidb-ansible
3 ansible-playbook -i hosts.ini deploy_ntp.yml -u tidb -b

目标机器上调整cpufreq

1 # 查看cpupower 调节模式,目前虚拟机不支持,调节10服务器cpupower
2 cpupower frequency-info --governors
3 analyzing cpu 0:
4 available cpufreq governors: not available
5 # 配置cpufreq调节模式
6 cpupower frequency-set --governor performance

目标机器上添加数据盘ext4 文件系统挂载

 1 # 创建分区表
 2 parted -s -a optimal /dev/nvme0n1 mklabel gpt -- mkpart primary ext4 1 -1
 3 # 手动创建分区
 4 parted dev/sdb
 5 mklabel gpt
 6 mkpart primary 0kb 210gb 
 7 # 格式化分区
 8 mkfs.ext4 /dev/sdb
 9 # 查看数据盘分区 uuid
10 [root@tidb-tikv1 ~]# lsblk -f
11 name fstype label uuid mountpoint
12 sda 
13 ├─sda1 xfs f41c3b1b-125f-407c-81fa-5197367feb39 /boot
14 ├─sda2 xfs 8119193b-c774-467f-a057-98329c66b3b3 /
15 ├─sda3 
16 └─sda5 xfs 42356bb3-911a-4dc4-b56e-815bafd08db2 /home
17 sdb ext4 532697e9-970e-49d4-bdba-df386cac34d2 
18 # 分别在三台机器上,编辑 /etc/fstab 文件,添加 nodelalloc 挂载参数
19 vim /etc/fstab
20 uuid=8119193b-c774-467f-a057-98329c66b3b3 / xfs defaults 0 0
21 uuid=f41c3b1b-125f-407c-81fa-5197367feb39 /boot xfs defaults 0 0
22 uuid=42356bb3-911a-4dc4-b56e-815bafd08db2 /home xfs defaults 0 0
23 uuid=532697e9-970e-49d4-bdba-df386cac34d2 /data ext4 defaults,nodelalloc,noatime 0 2
24 # 挂载数据盘
25 mkdir /data
26 mount -a
27 mount -t ext4
28 /dev/sdb on /data type ext4 (rw,noatime,seclabel,nodelalloc,data=ordered)

分配机器资源,编辑inventory.ini 文件

 1 # 单机tikv实例
 2 name hostip services
 3 tidb-tikv1 172.16.5.50 pd1, tidb1, tikv1
 4 tidb-tikv2 172.16.5.51 pd2, tikv2
 5 tidb-tikv3 172.16.5.52 pd3, tikv3
 6 # 编辑inventory.ini 文件
 7 cd /home/tidb/tidb-ansible
 8 vim inventory.ini
 9 ## tidb cluster part
10 [tidb_servers]
11 172.16.5.50
12 172.16.5.51
13 
14 [tikv_servers]
15 172.16.5.50
16 172.16.5.51
17 172.16.5.52
18 
19 [pd_servers]
20 172.16.5.50
21 172.16.5.51
22 172.16.5.52
23 
24 ## monitoring part
25 # prometheus and pushgateway servers
26 [monitoring_servers]
27 172.16.5.50
28 
29 # node_exporter and blackbox_exporter servers
30 [monitored_servers]
31 172.16.5.50
32 172.16.5.51
33 172.16.5.52
34 
35 [all:vars]
36 #deploy_dir = /home/tidb/deploy
37 deploy_dir = /data/deploy
38 # 检测ssh互信
39 [tidb@tidb-tikv1 tidb-ansible]$ ansible -i inventory.ini all -m shell -a 'whoami'
40 172.16.5.51 | success | rc=0 >>
41 tidb
42 172.16.5.52 | success | rc=0 >>
43 tidb
44 172.16.5.50 | success | rc=0 >>
45 tidb
46 # 检测tidb 用户 sudo 免密码配置
47 [tidb@tidb-tikv1 tidb-ansible]$ ansible -i inventory.ini all -m shell -a 'whoami' -b
48 172.16.5.52 | success | rc=0 >>
49 root
50 172.16.5.51 | success | rc=0 >>
51 root
52 172.16.5.50 | success | rc=0 >>
53 root
54 # 执行 local_prepare.yml playbook,联网下载 tidb binary 到中控机
55 ansible-playbook local_prepare.yml
56 # 初始化系统环境,修改内核参数
57 ansible-playbook bootstrap.yml

2.2、安装tidb集群

1 ansible-playbook deploy.yml

2.3、启动tidb集群

1 ansible-playbook start.yml

2.4、测试集群

 1 # 使用 mysql 客户端连接测试,tcp 4000 端口是 tidb 服务默认端口
 2 mysql -u root -h 172.16.5.50 -p 4000
 3 mysql> show databases;
 4 +--------------------+
 5 | database |
 6 +--------------------+
 7 | information_schema |
 8 | performance_schema |
 9 | mysql |
10 | test |
11 +--------------------+
12 4 rows in set (0.00 sec)
13 # 通过浏览器访问监控平台
14 地址:http://172.16.5.51:3000 默认帐号密码是:admin/admin

 三、tidb集群扩容

 3.1、扩容 tidb/tikv 节点

 1 # 单机tikv实例
 2 name hostip services
 3 tidb-tikv1 172.16.5.50 pd1, tidb1, tikv1
 4 tidb-tikv2 172.16.5.51 pd2, tikv2
 5 tidb-tikv3 172.16.5.52 pd3, tikv3
 6 # 新增一台tidb节点
 7 添加一个 tidb 节点(tidb-tikv4),ip 地址为 172.16.5.53
 8 # 编辑inventory.ini 文件
 9 cd /home/tidb/tidb-ansible
10 vim inventory.ini
------------------start--------------------------- 11 ## tidb cluster part 12 [tidb_servers] 13 172.16.5.50 14 172.16.5.51 15 172.16.5.53 16 17 [tikv_servers] 18 172.16.5.50 19 172.16.5.51 20 172.16.5.52 21 22 [pd_servers] 23 172.16.5.50 24 172.16.5.51 25 172.16.5.52 26 27 ## monitoring part 28 # prometheus and pushgateway servers 29 [monitoring_servers] 30 172.16.5.50 31 32 # node_exporter and blackbox_exporter servers 33 [monitored_servers] 34 172.16.5.50 35 172.16.5.51 36 172.16.5.52 37 172.16.5.53
----------------------end-------------------
38 # 拓扑结构如下 39 name hostip services 40 tidb-tikv1 172.16.5.50 pd1, tidb1, tikv1 41 tidb-tikv2 172.16.5.51 pd2, tikv2 42 tidb-tikv3 172.16.5.52 pd3, tikv3 43 tidb-tikv4 172.16.5.53 tidb2 44 # 初始化新增节点 45 ansible-playbook bootstrap.yml -l 172.16.5.53 46 # 部署新增节点 47 ansible-playbook deploy.yml -l 172.16.5.53 48 # 启动新节点服务 49 ansible-playbook start.yml -l 172.16.5.53 50 # 更新 prometheus 配置并重启 51 ansible-playbook rolling_update_monitor.yml --tags=prometheus

3.2、扩容pd节点

 1 # 拓扑结构如下# 单机tikv实例
 2 name hostip services
 3 tidb-tikv1 172.16.5.50 pd1, tidb1, tikv1
 4 tidb-tikv2 172.16.5.51 pd2, tikv2
 5 tidb-tikv3 172.16.5.52 pd3, tikv3
 6 # 新增一台pd节点
 7 添加一个 pd 节点(tidb-pd1),ip 地址为 172.16.5.54
 8 # 编辑inventory.ini 文件
 9 cd /home/tidb/tidb-ansible
10 vim inventory.ini
11 ## tidb cluster part
12 [tidb_servers]
13 172.16.5.50
14 172.16.5.51
15 
16 [tikv_servers]
17 172.16.5.50
18 172.16.5.51
19 172.16.5.52
20 
21 [pd_servers]
22 172.16.5.50
23 172.16.5.51
24 172.16.5.52
25 172.16.5.54
26 
27 ## monitoring part
28 # prometheus and pushgateway servers
29 [monitoring_servers]
30 172.16.5.50
31 
32 # node_exporter and blackbox_exporter servers
33 [monitored_servers]
34 172.16.5.50
35 172.16.5.51
36 172.16.5.52
37 172.16.5.54
38 # 拓扑结构如下
39 name hostip services
40 tidb-tikv1 172.16.5.50 pd1, tidb1, tikv1
41 tidb-tikv2 172.16.5.51 pd2, tikv2
42 tidb-tikv3 172.16.5.52 pd3, tikv3
43 tidb-pd1 172.16.5.54 pd4
44 # 初始化新增节点
45 ansible-playbook bootstrap.yml -l 172.16.5.54
46 # 部署新增节点
47 ansible-playbook deploy.yml -l 172.16.5.54
48 # 登录新增的 pd 节点,编辑启动脚本:{deploy_dir}/scripts/run_pd.sh
49 1、移除 --initial-cluster="xxxx" \ 配置。
50 2、添加 --join="http://172.16.10.1:2379" \,ip 地址 (172.16.10.1) 可以是集群内现有 pd ip 地址中的任意一个。
51 3、在新增 pd 节点中手动启动 pd 服务:
52 {deploy_dir}/scripts/start_pd.sh
53 4、使用 pd-ctl 检查新节点是否添加成功:
54 /home/tidb/tidb-ansible/resources/bin/pd-ctl -u "http://172.16.10.1:2379" -d member
55 # 滚动升级整个集群
56 ansible-playbook rolling_update.yml
57 # 更新 prometheus 配置并重启
58 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

性能测试

  1 # cpu性能测试
  2 sysbench --test=cpu --cpu-max-prime=20000 run
  3 ----------------------------------start----------------------------------------
  4 number of threads: 1
  5 initializing random number generator from current time
  6 prime numbers limit: 20000
  7 initializing worker threads...
  8 threads started!
  9 cpu speed:
 10 events per second: 286.71
 11 general statistics:
 12 total time: 10.0004s
 13 total number of events: 2868
 14 latency (ms):
 15 min: 3.46
 16 avg: 3.49
 17 max: 4.49
 18 95th percentile: 3.55
 19 sum: 9997.23
 20 threads fairness:
 21 events (avg/stddev): 2868.0000/0.00
 22 execution time (avg/stddev): 9.9972/0.00
 23 -----------------------------------end-------------------------------------------
 24 # 线程测试
 25 sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run
 26 ------------------------------------start-----------------------------------------
 27 number of threads: 64
 28 initializing random number generator from current time
 29 initializing worker threads...
 30 threads started!
 31 general statistics:
 32 total time: 10.0048s
 33 total number of events: 108883
 34 latency (ms):
 35 min: 0.05
 36 avg: 5.88
 37 max: 49.15
 38 95th percentile: 17.32
 39 sum: 640073.32
 40 threads fairness:
 41 events (avg/stddev): 1701.2969/36.36
 42 execution time (avg/stddev): 10.0011/0.00
 43 -----------------------------------end-----------------------------------------
 44 # 磁盘io测试
 45 sysbench --test=fileio --num-threads=16 --file-total-size=3g --file-test-mode=rndrw prepare
 46 ----------------------------------start-----------------------------------------
 47 128 files, 24576kb each, 3072mb total
 48 creating files for the test...
 49 extra file open flags: (none)
 50 creating file test_file.0
 51 creating file test_file.1
 52 creating file test_file.2
 53 creating file test_file.3
 54 creating file test_file.4
 55 creating file test_file.5
 56 creating file test_file.6
 57 creating file test_file.7
 58 creating file test_file.8
 59 creating file test_file.9
 60 creating file test_file.10
 61 creating file test_file.11
 62 creating file test_file.12
 63 creating file test_file.13
 64 creating file test_file.14
 65 creating file test_file.15
 66 creating file test_file.16
 67 creating file test_file.17
 68 creating file test_file.18
 69 creating file test_file.19
 70 creating file test_file.20
 71 creating file test_file.21
 72 creating file test_file.22
 73 creating file test_file.23
 74 creating file test_file.24
 75 creating file test_file.25
 76 creating file test_file.26
 77 creating file test_file.27
 78 creating file test_file.28
 79 creating file test_file.29
 80 creating file test_file.30
 81 creating file test_file.31
 82 creating file test_file.32
 83 creating file test_file.33
 84 creating file test_file.34
 85 creating file test_file.35
 86 creating file test_file.36
 87 creating file test_file.37
 88 creating file test_file.38
 89 creating file test_file.39
 90 creating file test_file.40
 91 creating file test_file.41
 92 creating file test_file.42
 93 creating file test_file.43
 94 creating file test_file.44
 95 creating file test_file.45
 96 creating file test_file.46
 97 creating file test_file.47
 98 creating file test_file.48
 99 creating file test_file.49
100 creating file test_file.50
101 creating file test_file.51
102 creating file test_file.52
103 creating file test_file.53
104 creating file test_file.54
105 creating file test_file.55
106 creating file test_file.56
107 creating file test_file.57
108 creating file test_file.58
109 creating file test_file.59
110 creating file test_file.60
111 creating file test_file.61
112 creating file test_file.62
113 creating file test_file.63
114 creating file test_file.64
115 creating file test_file.65
116 creating file test_file.66
117 creating file test_file.67
118 creating file test_file.68
119 creating file test_file.69
120 creating file test_file.70
121 creating file test_file.71
122 creating file test_file.72
123 creating file test_file.73
124 creating file test_file.74
125 creating file test_file.75
126 creating file test_file.76
127 creating file test_file.77
128 creating file test_file.78
129 creating file test_file.79
130 creating file test_file.80
131 creating file test_file.81
132 creating file test_file.82
133 creating file test_file.83
134 creating file test_file.84
135 creating file test_file.85
136 creating file test_file.86
137 creating file test_file.87
138 creating file test_file.88
139 creating file test_file.89
140 creating file test_file.90
141 creating file test_file.91
142 creating file test_file.92
143 creating file test_file.93
144 creating file test_file.94
145 creating file test_file.95
146 creating file test_file.96
147 creating file test_file.97
148 creating file test_file.98
149 creating file test_file.99
150 creating file test_file.100
151 creating file test_file.101
152 creating file test_file.102
153 creating file test_file.103
154 creating file test_file.104
155 creating file test_file.105
156 creating file test_file.106
157 creating file test_file.107
158 creating file test_file.108
159 creating file test_file.109
160 creating file test_file.110
161 creating file test_file.111
162 creating file test_file.112
163 creating file test_file.113
164 creating file test_file.114
165 creating file test_file.115
166 creating file test_file.116
167 creating file test_file.117
168 creating file test_file.118
169 creating file test_file.119
170 creating file test_file.120
171 creating file test_file.121
172 creating file test_file.122
173 creating file test_file.123
174 creating file test_file.124
175 creating file test_file.125
176 creating file test_file.126
177 creating file test_file.127
178 3221225472 bytes written in 339.76 seconds (9.04 mib/sec)
179 ----------------------------------end------------------------------------------
180 sysbench --test=fileio --num-threads=16 --file-total-size=3g --file-test-mode=rndrw run
181 ----------------------------------start-----------------------------------------
182 number of threads: 16
183 initializing random number generator from current time
184 extra file open flags: (none)
185 128 files, 24mib each
186 3gib total file size
187 block size 16kib
188 number of io requests: 0
189 read/write ratio for combined random io test: 1.50
190 periodic fsync enabled, calling fsync() each 100 requests.
191 calling fsync() at the end of test, enabled.
192 using synchronous i/o mode
193 doing random r/w test
194 initializing worker threads...
195 threads started!
196 file operations:
197 reads/s: 299.19
198 writes/s: 199.46
199 fsyncs/s: 816.03
200 throughput:
201 read, mib/s: 4.67
202 written, mib/s: 3.12
203 general statistics:
204 total time: 10.8270s
205 total number of events: 12189
206 latency (ms):
207 min: 0.00
208 avg: 13.14
209 max: 340.58
210 95th percentile: 92.42
211 sum: 160186.15
212 threads fairness:
213 events (avg/stddev): 761.8125/216.01
214 execution time (avg/stddev): 10.0116/0.01
215 --------------------------------------end---------------------------------------
216 sysbench --test=fileio --num-threads=16 --file-total-size=3g --file-test-mode=rndrw cleanup
217 # 内存测试
218 sysbench --test=memory --memory-block-size=8k --memory-total-size=4g run 
219 ------------------------------------start-----------------------------------------
220 number of threads: 1
221 initializing random number generator from current time
222 running memory speed test with the following options:
223 block size: 8kib
224 total size: 4096mib
225 operation: write
226 scope: global
227 initializing worker threads...
228 threads started!
229 total operations: 524288 (1111310.93 per second)
230 4096.00 mib transferred (8682.12 mib/sec)
231 general statistics:
232 total time: 0.4692s
233 total number of events: 524288
234 latency (ms):
235 min: 0.00
236 avg: 0.00
237 max: 0.03
238 95th percentile: 0.00
239 sum: 381.39
240 
241 threads fairness:
242 events (avg/stddev): 524288.0000/0.00
243 execution time (avg/stddev): 0.3814/0.00
244 -------------------------------------end---------------------------------------

4.2、oltp测试

 1 # 登录tidb创建测试数据库
 2 mysql -u root -p 4000 -h 172.16.5.50
 3 create database sbtest
 4 # 准备测试数据
 5 sysbench /usr/share/sysbench/oltp_common.lua --mysql-host=172.16.5.50 --mysql-port=4000 --mysql-user=root --tables=20 --table_size=20000000 --threads=100 --max-requests=0 prepare
 6 --tables=20 # 创建20个表
 7 --table_size=20000000 # 每个表两千万数据
 8 --threads=100 # 使用100个线程数
 9 ---------------------------------报错信息如下------------------------------------------
10 fatal: mysql_drv_query() returned error 9001 (pd server timeout[try again later]
11 2018/11/23 11:23:19.236 log.go:82: [warning] etcdserver: [timed out waiting for read index response]
12 2018/11/23 14:15:17.329 heartbeat_streams.go:97: [error] [store 1] send keepalive message fail: eof
13 2018/11/23 14:14:04.603 leader.go:312: [info] leader is deleted
14 2018/11/23 14:14:04.603 leader.go:103: [info] pd2 is not etcd leader, skip campaign leader and check later
15 2018/11/23 14:21:10.071 coordinator.go:570: [info] [region 1093] send schedule command: transfer leader from store 7 to store 2
16 fatal: mysql_drv_query() returned error 1105 (information schema is out of date)
17 ------------------------------------end-----------------------------------------------
18 # 调整线程数为10,表数量为10,表数据为2000000 做测试
19 sysbench /usr/share/sysbench/oltp_common.lua --mysql-host=172.16.5.50 --mysql-port=4000 --mysql-user=root --tables=1 --table_size=2000000 --threads=10 --max-requests=0 prepare
20 --------------------------------------start--------------------------------------------
21 fatal: mysql_drv_query() returned error 1105 (information schema is out of date) 超时报错
22 成功写入2张表,其余8张表数据并未写满,写好索引
23 # 对tidb集群进行读写测试
24 sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=172.16.5.50 --mysql-port=4000 --mysql-user=root --tables=1 --table_size=2000000 --threads=10 --max-requests=0 run
25 ----------------------------------------start--------------------------------------
26 number of threads: 10
27 initializing random number generator from current time
28 initializing worker threads...
29 threads started!
30 sql statistics:
31 queries performed:
32 read: 868
33 write: 62
34 other: 310
35 total: 1240
36 transactions: 62 (5.60 per sec.)
37 queries: 1240 (112.10 per sec.)
38 ignored errors: 0 (0.00 per sec.)
39 reconnects: 0 (0.00 per sec.)
40 general statistics:
41 total time: 11.0594s
42 total number of events: 62
43 latency (ms):
44 min: 944.55
45 avg: 1757.78
46 max: 2535.05
47 95th percentile: 2320.55
48 sum: 108982.56
49 threads fairness:
50 events (avg/stddev): 6.2000/0.40
51 execution time (avg/stddev): 10.8983/0.31
52 ------------------------------------end----------------------------------------
53 # 使用mysql对比测试
54 mysql -uroot -p 3306 -h 172.15.5.154
55 create database sbtest
56 sysbench /usr/share/sysbench/oltp_common.lua --mysql-host=172.16.5.154 --mysql-port=3306 --mysql-user=root --mysql-password=root --tables=20 --table_size=20000000 --threads=10 --max-requests=0 prepare
57 使用mysql 做测试未发现报错情况

4.3、业务数据测试

1 sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=172.16.5.50 --mysql-port=4000 --mysql-user=root --tables=20 --table_size=2000000 --threads=10 --max-requests=0 run