安装:
下载:https://github.com/Percona-Lab/tpcc-mysql
解压:unzip tpcc-mysql-master.zip
cd tpcc-mysql-master/src
make
make后会在 tpcc-mysql-master 路径下生成 tpcc_load 和 tpcc_start 可执行文件
到这里安装完成
使用:
1.加载数据
现在mysql中创建1个库(tpcc,名字随便取)
2.建表
tpcc-mysql-master 路径下有脚本,create_table.sql,直接导入就行
mysql tpcc < create_table.sql
3.导入数据 tpcc_load
用法:
[root@test3 tpcc-mysql-master]# ./tpcc_load --help
*************************************
*** TPCC-mysql Data Loader ***
*************************************
./tpcc_load: invalid option -- '-'
Usage: tpcc_load -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -l part -m min_wh -n max_wh
* [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
[root@test3 tpcc-mysql-master]# ./tpcc_load -h 192.168.65.3 -P 3306 -d tpcc -u root -p 123 -w 2
*************************************
*** TPCC-mysql Data Loader ***
*************************************
option h with value '192.168.65.3'
option P with value '3306'
option d with value 'tpcc'
option u with value 'root'
option p with value '123'
option w with value '2'
<Parameters>
[server]: 192.168.65.3
[port]: 3306
[DBname]: tpcc
[user]: root
[pass]: 123
[warehouse]: 2
TPCC Data Load Started...
Loading Item
.................................................. 5000
.................................................. 10000
.................................................. 15000
.................................................. 20000
.................................................. 25000
.................................................. 30000
.................................................. 35000
.................................................. 40000
…………
4.建索引
tpcc-mysql-master 路径下有脚本,add_fkey_idx.sql,直接导入就行
mysql tpcc < add_fkey_idx.sql
5.测试
语法:
[root@test3 tpcc-mysql-master]# ./tpcc_start --help
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
./tpcc_start: invalid option -- '-'
Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file -t trx_file
-w: 仓库数
-c:连接数
-r:预热时间
-l:测试时长
-i:打印间隔,默认10s
-f:报告文件
[root@test2 tpcc-mysql-master]# ./tpcc_start -h 192.168.65.2 -P 3306 -d tpcc -u root -p 123 -w 2 -c 10 -r 3 -l 15 -i 3
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value '192.168.65.2'
option P with value '3306'
option d with value 'tpcc'
option u with value 'root'
option p with value '123'
option w with value '2'
option c with value '10'
option r with value '3'
option l with value '15'
option i with value '3'
<Parameters>
[server]: 192.168.65.2
[port]: 3306
[DBname]: tpcc
[user]: root
[pass]: 123
[warehouse]: 2
[connection]: 10
[rampup]: 3 (sec.)
[measure]: 15 (sec.)
RAMP-UP TIME.(3 sec.) 这里的 3s 就是越热时间
MEASURING START.
3, trx: 395, 95%: 72.779, 99%: 140.146, max_rt: 333.572, 391|216.818, 39|91.448, 40|408.366, 39|352.061
6, trx: 238, 95%: 79.261, 99%: 101.707, max_rt: 129.408, 239|158.726, 25|62.082, 23|213.098, 24|217.911
9, trx: 317, 95%: 61.695, 99%: 74.722, max_rt: 137.816, 321|142.896, 31|44.302, 32|165.921, 32|186.620
12, trx: 390, 95%: 51.367, 99%: 68.714, max_rt: 84.335, 391|127.852, 40|56.649, 39|160.820, 39|129.003
15, trx: 337, 95%: 55.942, 99%: 66.171, max_rt: 85.197, 336|117.524, 32|67.765, 34|169.994, 33|180.630
STOPPING THREADS..........
<Raw Results>
[0] sc:13 lt:1664 rt:0 fl:0 avg_rt: 38.1 (5) sc:成功次数; lt:延迟次数; rt:重试次数; fl:失败次数
[1] sc:39 lt:1639 rt:0 fl:0 avg_rt: 42.5 (5)
[2] sc:28 lt:139 rt:0 fl:0 avg_rt: 22.1 (5)
[3] sc:49 lt:119 rt:0 fl:0 avg_rt: 118.6 (80)
[4] sc:0 lt:167 rt:0 fl:0 avg_rt: 117.7 (20)
in 15 sec.
<Raw Results2(sum ver.)>
[0] sc:13 lt:1664 rt:0 fl:0
[1] sc:39 lt:1639 rt:0 fl:0
[2] sc:28 lt:139 rt:0 fl:0
[3] sc:49 lt:119 rt:0 fl:0
[4] sc:0 lt:167 rt:0 fl:0
<Constraint Check> (all must be [OK])
[transaction percentage]
Payment: 43.51% (>=43.0%) [OK]
Order-Status: 4.33% (>= 4.0%) [OK]
Delivery: 4.36% (>= 4.0%) [OK]
Stock-Level: 4.33% (>= 4.0%) [OK]
[response time (at least 90% passed)]
New-Order: 0.78% [NG] * 这里必须全部ok才算测试通过
Payment: 2.32% [NG] *
Order-Status: 16.77% [NG] *
Delivery: 29.17% [NG] *
Stock-Level: 0.00% [NG] *
<TpmC>
6708.000 TpmC -- TpmC结果值(每分钟事务数,该值是第一次统计结果中的新订单事务数除以总耗时分钟数,例如本例中是:372/2=186)