官网下载地址:

http://imysql.com/wp-content/uploads/2014/09/tpcc-mysql-src.tgz

1.用bzr客户端下载软件包

[root@tong1 ~]# yum install bzr -y

[root@tong1 ~]# bzr branch lp:~percona-dev/perconatools/tpcc-mysql

[root@tong1 ~]# cd tpcc-mysql/src/

[root@tong1 src]# make

[root@tong1 src]# cd ..
[root@tong1 tpcc-mysql]# ll
total 252
-rw-r--r--. 1 root root   1621 Apr 23 11:24 add_fkey_idx.sql
-rw-r--r--. 1 root root    317 Apr 23 11:24 count.sql
-rw-r--r--. 1 root root   3105 Apr 23 11:24 create_table.sql
-rw-r--r--. 1 root root    763 Apr 23 11:24 drop_cons.sql
-rw-r--r--. 1 root root    477 Apr 23 11:24 load.sh
-rw-r--r--. 1 root root    851 Apr 23 11:24 README
drwxr-xr-x. 2 root root   4096 Apr 23 11:24 schema2
drwxr-xr-x. 5 root root   4096 Apr 23 11:24 scripts
drwxr-xr-x. 2 root root   4096 Apr 23 11:25 src
-rwxr-xr-x. 1 root root  61191 Apr 23 11:25 tpcc_load        --make后生成的命令
-rwxr-xr-x. 1 root root 155886 Apr 23 11:25 tpcc_start       --make后生成的命令

[root@tong1 tpcc-mysql]# 


2.创建数据库导入表结构

[root@tong1 tpcc-mysql]# mysqladmin  create tpcc;
[root@tong1 tpcc-mysql]# mysql tpcc < create_table.sql
[root@tong1 tpcc-mysql]#


3.加载测试数据(tpcc_load)

[root@tong1 tpcc-mysql]# ./tpcc_load  --help
*************************************
*** ###easy### TPC-C Data Loader  ***
*************************************

 usage: tpcc_load [server] [DB] [user] [pass] [warehouse]
      OR
        tpcc_load [server] [DB] [user] [pass] [warehouse] [part] [min_wh] [max_wh]

           * [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
[root@tong1 tpcc-mysql]# ./tpcc_load  localhost tpcc root "" 100   --机械硬件仓库数不能少于100个,ssd硬件不能少于1000个


4.压力测试数据(tpcc_start)

[root@tong1 tpcc-mysql]# ./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

-h      --mysql的主机

-P      --服务的端口

-d      --测试的数据库

-u      --用户名

-p      --密码

-w      --仓库个数

-c      --连接数

-r      --测试前热身的时间

-l      --测试运行的时间

-i      --生成报告时间

-f      --指定生成报告文件

[root@tong1 tpcc-mysql]# ./tpcc_start  -h localhost -P 3306 -d tpcc -u root -p "" -w 100 -c 100 -r 120 -l 360 -f 123.log >> tpcc-mysql.log 2>&1

[root@tong1 tpcc-mysql]# cat tpcc-mysql.log
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value 'localhost'
option P with value '3306'
option d with value 'tpcc'
option u with value 'root'
option p with value ''
option w with value '100'
option c with value '100'
option r with value '120'
option l with value '360'
option f with value '123.log'

     [server]: localhost
     [port]: 3306
     [DBname]: tpcc
       [user]: root
       [pass]:
  [warehouse]: 100
 [connection]: 100
     [rampup]: 120 (sec.)
    [measure]: 360 (sec.)

RAMP-UP TIME.(120 sec.)          --预热时间120S

MEASURING START.           --每10S收集的信息

  10, 27(0):1.191|1.236, 27(0):0.341|0.433, 6(0):0.180|0.188, 2(0):1.567|1.570, 0(0):3.804|3.933
  20, 46(0):1.417|1.501, 26(0):0.348|0.357, 2(0):0.171|0.175, 5(0):1.417|1.477, 1(0):0.000|4.351
  30, 16(0):1.358|1.508, 19(0):0.398|0.681, 3(0):0.183|0.229, 2(0):1.310|1.429, 2(0):5.050|5.904
  40, 9(0):1.348|1.438, 18(0):0.322|0.334, 0(0):0.000|0.000, 2(0):1.228|1.284, 3(0):5.657|6.583
  50, 56(0):1.463|1.465, 27(0):0.310|0.393, 2(0):0.082|0.151, 5(0):1.451|1.555, 0(0):0.000|0.000
  60, 16(0):1.223|1.237, 25(0):0.324|0.352, 5(0):0.161|0.163, 2(0):1.253|1.432, 1(0):0.000|5.627
  70, 25(0):1.177|1.368, 31(0):0.324|0.348, 2(0):0.156|0.170, 1(0):0.000|1.342, 3(0):5.473|6.178
  80, 31(0):1.374|1.394, 15(0):0.275|0.284, 2(0):0.111|0.153, 3(0):1.345|1.431, 2(0):5.026|5.289
  90, 15(0):1.220|1.229, 34(0):0.291|0.310, 5(0):0.167|0.180, 1(0):0.000|1.396, 4(0):5.004|5.702
 100, 21(0):1.372|1.410, 27(0):0.313|0.509, 1(0):0.000|0.107, 2(0):1.487|1.524, 3(0):5.687|5.866
 110, 29(0):1.401|1.438, 18(0):0.367|0.422, 1(0):0.000|0.118, 5(0):1.411|1.437, 0(0):0.000|0.000
 120, 44(0):1.354|1.444, 30(0):0.320|0.329, 1(0):0.000|0.170, 2(0):1.380|1.459, 2(0):5.083|5.109
 130, 20(0):1.432|1.458, 15(0):0.299|0.318, 6(0):0.176|0.177, 3(0):1.483|1.517, 6(0):5.519|5.721
 140, 3(0):0.848|0.957, 37(0):0.437|0.531, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000
 150, 21(0):1.337|1.394, 13(0):0.291|0.326, 3(0):0.149|0.158, 4(0):1.492|1.493, 3(0):5.839|6.008
 160, 47(0):1.419|1.427, 39(0):0.355|0.378, 1(0):0.000|0.157, 3(0):1.381|1.453, 4(0):5.484|5.749
 170, 4(0):1.214|1.393, 15(0):0.287|0.305, 6(0):0.186|0.210, 1(0):0.000|1.306, 4(0):5.174|5.803
 180, 40(0):1.304|1.399, 21(0):0.343|0.369, 1(0):0.000|0.133, 3(0):1.325|1.438, 2(0):3.857|4.854
 190, 28(0):1.366|1.755, 36(0):0.358|0.367, 0(0):0.000|0.000, 5(0):1.388|1.412, 1(0):0.000|5.540
 200, 30(0):1.393|1.711, 26(0):0.311|0.328, 6(0):0.173|0.199, 1(0):0.000|1.414, 3(0):5.008|5.151
 210, 19(0):1.213|1.376, 30(0):0.387|0.389, 1(0):0.000|0.106, 0(0):0.000|0.000, 5(0):4.882|5.416
 220, 45(0):1.420|1.563, 27(0):0.329|0.368, 4(0):0.164|0.167, 1(0):0.000|1.420, 1(0):0.000|2.990
 230, 32(0):1.513|1.654, 19(0):0.330|0.339, 1(0):0.000|0.157, 4(0):1.399|1.427, 5(0):5.612|5.668
 240, 42(0):1.344|1.556, 42(0):0.328|0.428, 6(0):0.175|0.179, 2(0):1.417|1.454, 2(0):3.330|5.057
 250, 15(0):1.476|1.486, 25(0):0.324|0.345, 3(0):0.175|0.186, 5(0):1.427|1.511, 4(0):5.543|5.985
 260, 14(0):1.331|1.346, 30(0):0.360|0.364, 0(0):0.000|0.000, 2(0):1.375|1.599, 1(0):0.000|5.458
 270, 19(0):1.302|1.371, 24(0):0.299|0.331, 5(0):0.170|0.186, 6(0):1.563|1.570, 2(0):5.232|5.413
 280, 25(0):1.413|1.532, 19(0):0.268|0.276, 3(0):0.108|0.118, 1(0):0.000|1.393, 6(0):5.310|5.910
 290, 69(0):1.511|1.522, 30(0):0.369|0.407, 0(0):0.000|0.000, 2(0):1.313|1.314, 5(0):5.994|6.222
 300, 12(0):0.896|1.564, 33(0):0.359|0.383, 4(0):0.172|0.184, 3(0):1.406|1.561, 1(0):0.000|5.595
 310, 49(0):1.521|1.921, 39(0):0.390|0.443, 3(0):0.132|0.168, 6(0):1.592|1.648, 3(0):5.782|5.803
 320, 22(0):1.630|1.695, 39(0):0.326|0.414, 0(0):0.000|0.000, 0(0):0.000|0.000, 2(0):5.164|6.518
 330, 7(0):1.399|1.561, 12(0):0.291|0.328, 7(0):0.161|0.186, 0(0):0.000|0.000, 1(0):0.000|4.457
 340, 54(0):1.430|1.526, 32(0):0.336|0.355, 0(0):0.000|0.000, 2(0):1.403|1.482, 3(0):6.415|6.459
 350, 4(0):0.637|0.652, 16(0):0.372|0.776, 5(0):0.168|0.171, 5(0):1.427|1.478, 1(0):0.000|3.920
 360, 37(0):1.392|1.422, 30(0):0.383|0.449, 2(0):0.139|0.172, 5(0):1.599|1.612, 0(0):0.000|0.000

STOPPING THREADS....................................................................................................


  [0] sc:993  lt:0  rt:0  fl:0
  [1] sc:946  lt:0  rt:0  fl:0
  [2] sc:97  lt:0  rt:0  fl:0
  [3] sc:96  lt:0  rt:0  fl:0
  [4] sc:86  lt:0  rt:0  fl:0
 in 360 sec.


  [0] sc:993  lt:0  rt:0  fl:0     --新订单业务成功(success简写sc)次数,延迟(late简写lt)次数,重试(retry简写rt)次数,失败(failure简写fl)次数

  [1] sc:953  lt:0  rt:0  fl:0     --支付业务统计

  [2] sc:97  lt:0  rt:0  fl:0      --订单状态业务统计
  [3] sc:96  lt:0  rt:0  fl:0      --发货业务统计
  [4] sc:86  lt:0  rt:0  fl:0      --库存业务统计

(all must be [OK])         --以下必须全部是OK状态
 [transaction percentage]
        Payment: 42.65% (>=43.0%) [NG] *      --支付成功率次数
   Order-Status: 4.37% (>= 4.0%) [OK]         --订单状态
       Delivery: 4.33% (>= 4.0%) [OK]         --发贷
    Stock-Level: 3.88% (>= 4.0%) [NG] *       --库存
 [response time (at least 90% passed)]        --响应时间必须超过90%才行
      New-Order: 100.00%  [OK]       

        Payment: 100.00%  [OK]       

       Delivery: 100.00%  [OK]       
    Stock-Level: 100.00%  [OK]       


                 165.500 TpmC     --最终结果,每分钟事物数
[root@tong1 tpcc-mysql]#


5.sql脚本说明

[root@tong1 tpcc-mysql]# ll *.sql
-rw-r--r--. 1 root root 1621 Apr 23 11:24 add_fkey_idx.sql    --给创建添加外键和索引
-rw-r--r--. 1 root root  317 Apr 23 11:24 count.sql           --统计各表中有多少行数据
-rw-r--r--. 1 root root 3105 Apr 23 11:24 create_table.sql    --创建测试表
-rw-r--r--. 1 root root  763 Apr 23 11:24 drop_cons.sql       --删除外键约束
[root@tong1 tpcc-mysql]# 


6.shell脚本说明

[root@tong1 tpcc-mysql]# cd scripts/
[root@tong1 scripts]# ll *.sh
-rw-r--r--. 1 root root 2044 Apr 23 11:24 anal.full.sh
-rw-r--r--. 1 root root  114 Apr 23 11:24 analyze_checkpoint.sh
-rw-r--r--. 1 root root  162 Apr 23 11:24 analyze_checkpoint_xtradb1.sh
-rw-r--r--. 1 root root   85 Apr 23 11:24 analyze_checkpoint_xtradb.sh
-rw-r--r--. 1 root root  297 Apr 23 11:24 analyze_dirty.sh
-rw-r--r--. 1 root root  155 Apr 23 11:24 analyze_evicted.sh
-rw-r--r--. 1 root root   97 Apr 23 11:24 analyze_flushed_innodb.sh
-rw-r--r--. 1 root root  154 Apr 23 11:24 analyze_flushed.sh
-rw-r--r--. 1 root root  258 Apr 23 11:24 analyze_min.sh
-rw-r--r--. 1 root root  103 Apr 23 11:24 analyze_modified.sh
-rw-r--r--. 1 root root  452 Apr 23 11:24 analyzeR.sh
-rw-r--r--. 1 root root  363 Apr 23 11:24 analyze.sh
-rwxr-xr-x. 1 root root  101 Apr 23 11:24 flashcache_stat.sh
-rwxr-xr-x. 1 root root  116 Apr 23 11:24 innodb_stat.sh
-rw-r--r--. 1 root root 1766 Apr 23 11:24 run_no_backup.sh
-rw-r--r--. 1 root root 1363 Apr 23 11:24 run.sh
-rw-r--r--. 1 root root 2876 Apr 23 11:24 runX.sh
-rwxr-xr-x. 1 root root  167 Apr 23 11:24 virident_stat.sh
[root@tong1 scripts]#