gnuplot读取mysql数据库_Tpcc-MySQL测试并使用gnuplot生成图表

初始化表结构

点击(此处)折叠或打开

# 创建测试数据库, tpcc1000(随意)

mysql -uroot -ppwd -e 'create database tpcc1000;'

# 创建测试帐号:用户名,密码都是tpcc

mysql -uroot -ppwd -e "GRANT ALL ON tpcc1000.* TO 'tpcc'@'127.0.0.1' identified by 'tpcc';flush privileges;"

# 导入表结构、索引、外键等

mysql -h127.0.0.1 -utpcc -ptpcc tpcc1000 < create_table.sql

mysql -h127.0.0.1 -utpcc -ptpcc tpcc1000 < add_fkey_idx.sql

初始化测试数据

tpcc_load 生成多少个数据仓库数据。比较耗时

点击(此处)折叠或打开

# ./tpcc_load --help

tpcc_load [server] [DB] [user] [pass] [warehouse]

Server: 服务器名。host:port[3306]

DB: 数据库名

user: 用户名

pass: 密码

Warehouse: 仓库的数量

# 本机3306端口, 数据库tpcc1000, 用户名密码都是tpcc, 数据仓库100个

./tpcc_load 127.0.0.1:3306 tpcc1000 tpcc tpcc 100

进行压力测试

tpcc_start 进行压力测试

#./tpcc_start --help

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

-h server_host: 服务器名

-P port : 端口号,默认为3306

-d database_name: 数据库名

-u mysql_user : 用户名

-p mysql_password : 密码

-w warehouses: 仓库的数量

-c connections : 线程数,默认为1

-r warmup_time : 热身时间,单位:s,默认为10s ,热身是为了将数据加载到内存。

-l running_time: 测试时间,单位:s,默认为20s

-i report_interval: 指定生成报告间隔时长

-f report_file: 测试结果输出文件

注意

tpcc 默认会读取/var/lib/mysql/mysql.sock 这个socket位置,

如果mysql socket不在相应路径的话,就需要做个软连接,或者通过TCP/IP的方式连接测试服务器。

# 10个仓库,100个线程,热身30秒,测试120秒,输出到 tpcc.out

./tpcc_start -h127.0.0.1 -p3306 -dtpcc1000 -utpcc -ptpcc -w10 -c100 -r30 -l120  > tpcc.out

# 下一步分析脚本将分析蓝色部分的数据

点击(此处)折叠或打开

***************************************

*** ###easy### TPC-C Load Generator ***

***************************************

option h with value \'127.0.0.1\'

option p with value \'3306\'

option d with value \'tpcc1000\'

option u with value \'tpcc\'

option p with value \'tpcc\'

option w with value \'10\'

option c with value \'100\'

option r with value \'30\'

option l with value \'120\'

option f with value \'tpcc.out\'

[server]: 127.0.0.1

[port]: 3306

[DBname]: tpcc1000

[user]: tpcc

[pass]: tpcc

[warehouse]: 10

[connection]: 100

[rampup]: 30 (sec.)

[measure]: 120 (sec.)

RAMP-UP TIME.(30 sec.)

MEASURING START.

10, 153(0):2.453|2.829, 166(0):0.651|1.130, 17(0):0.352|0.466, 17(0):2.770|3.007, 23(0):7.171|7.935

20, 165(0):2.380|2.450, 156(0):0.457|0.484, 15(0):0.229|0.262, 18(0):2.653|2.688, 18(0):6.136|6.839

30, 162(0):2.372|2.440, 164(0):0.480|0.487, 17(0):0.269|0.272, 13(0):2.703|2.729, 17(0):6.009|6.535

40, 171(0):2.484|2.542, 171(0):0.478|0.493, 17(0):0.218|0.245, 18(0):2.811|2.854, 15(0):6.296|6.490

50, 173(0):2.437|2.515, 181(0):0.476|0.483, 18(0):0.233|0.240, 15(0):2.678|2.706, 19(0):6.402|6.762

60, 184(0):2.412|2.419, 205(0):0.459|0.488, 19(0):0.226|0.235, 21(0):2.700|2.726, 17(0):6.065|6.071

70, 182(0):2.322|2.438, 162(0):0.467|0.482, 18(0):0.228|0.233, 18(0):2.759|2.841, 19(0):6.177|6.368

80, 157(0):2.426|2.576, 164(0):0.468|0.476, 16(0):0.228|0.233, 15(0):2.671|2.707, 17(0):6.156|6.851

90, 188(0):2.459|2.484, 165(0):0.508|0.515, 18(0):0.261|0.274, 19(0):2.749|2.776, 18(0):6.283|6.402

100, 175(0):2.422|2.440, 195(0):0.484|0.493, 18(0):0.248|0.255, 17(0):2.657|2.664, 18(0):6.132|6.190

110, 176(0):2.346|2.398, 164(0):0.484|0.509, 17(0):0.228|0.229, 19(0):2.830|2.853, 18(0):6.128|6.452

120, 169(0):2.526|2.559, 176(0):0.514|0.553, 17(0):0.257|0.263, 16(0):2.781|3.103, 16(0):6.142|6.259

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

[0] sc:2055 lt:0 rt:0 fl:0

[1] sc:2069 lt:0 rt:0 fl:0

[2] sc:207 lt:0 rt:0 fl:0

[3] sc:206 lt:0 rt:0 fl:0

[4] sc:215 lt:0 rt:0 fl:0

in 120 sec.

[0] sc:2055 lt:0 rt:0 fl:0

[1] sc:2076 lt:0 rt:0 fl:0

[2] sc:207 lt:0 rt:0 fl:0

[3] sc:207 lt:0 rt:0 fl:0

[4] sc:215 lt:0 rt:0 fl:0

(all must be [OK])

[transaction percentage]

Payment: 43.54% (>=43.0%) [OK]

Order-Status: 4.36% (>= 4.0%) [OK]

Delivery: 4.34% (>= 4.0%) [OK]

Stock-Level: 4.52% (>= 4.0%) [OK]

[response time (at least 90% passed)]

New-Order: 100.00% [OK]

Payment: 100.00% [OK]

Order-Status: 100.00% [OK]

Delivery: 100.00% [OK]

Stock-Level: 100.00% [OK]

1027.500 TpmC

1. 业务逻辑

tpcc包括了4个业务逻辑: 1. New-Order:新订单

2. Order-Status:支付

3. Delivery:发货

4. Stock-Level:库存

2. late的定义

根据不同的业务,late的定义也不同,4种业务逻辑分别对操作延迟定义的界限值如下所示:

1. Payment 5ms

2. Order-Status 5ms

3. Delivery 80ms

4. Stock-Level 20ms

3. 数据意义

10, 2286(0):1.373|1.590, 2283(0):0.279|0.398, 228(0):0.148|0.208, 229(0):1.604|1.863, 228(0):4.438|4.993

二到六列数值组成格式是:  成功执行的次数(推迟执行的次数):90%事务的相应时间|最大相应时间

这一行有6列数据,意思分别是 1. 第一列:因为是10秒输出一句,所以这里代表的数据是0-10秒之间的结果。

2. 第二列:这一列是总的结果

3. 第三列:新订单业务的结果

4. 第四列:支付业务的结果

5. 第五列:发货业务的结果

6. 第六列:库存业务的结果

这里我们主要关注总的结果就行了。

4. TmpC的意义

tpmC是代表每分钟事务处理的数量。

分析测试数据

# 分析测试结果,并保存到tpcc.ana文件中

sh tpcc-analyze.sh tpcc.out > tpcc.ana

# 正常情况下会进行多个测试,则需要对每个结果进行分析,并产生相应的分析结果

# 测试分类: 同配置,同线程数,不同测试时间; 同配置,不同线程数; 不同配置

sh tpcc-analyze.sh tpcc.out.1 > tpcc.ana.1

sh tpcc-analyze.sh tpcc.out.2 > tpcc.ana.2

sh tpcc-analyze.sh tpcc.out.3 > tpcc.ana.3

# 合并分析结果(此出为2个)

paste tpcc.ana.1 tpcc.ana.2 > tpcc-graph.data

绘图(使用分析结果)

gnuplot使用说明

./tpcc-graph-build.sh tpcc-graph.data tpcc-graph.jpg

附shell脚本

tpcc-analyze.shTIMESLOT=1

if [ -n \"$2\" ]

then

TIMESLOT=$2

echo “Defined $2″

fi

cat $1 | grep -v HY000 | grep -v payment | grep -v neword | awk -v timeslot=$TIMESLOT 'BEGIN { FS=”[,():]“; s=0; cntr=0; aggr=0 } /MEASURING START/ { s=1} /STOPPING THREADS/ {s=0} /0/ { if (s==1) { cntr++; aggr+=$2; } if ( cntr==timeslot ) { printf (“%d %3d\\n”,$1,(aggr/’$TIMESLOT’)) ; cntr=0; aggr=0 } }'

tpcc-graph-build.sh

#!/bin/bash

### goto user homedir and remove previous file

rm -f ‘$2′

gnuplot << EOP

### set data source file

datafile = ‘$1′

### set graph type and size

set terminal jpeg size 640,480

### set titles

set grid x y

set xlabel “Time (sec)”

set ylabel “Transactions”

### set output filename

set output ‘$2′

### build graph

# plot datafile with lines

plot datafile using 1:2 title “Test Result 1: XXX ” with lines, \

datafile using 3:4 title “Test Result 2: XXX ” with lines axes x1y1

EOP

参考:[1]: http://blog.csdn.net/kyle__shaw/article/details/9666661 [2]: http://www.mysqlperformanceblog.com/2013/07/01/tpcc-mysql-simple-usage-steps-and-how-to-build-graphs-with-gnuplot/[3]: http://blog.chinaunix.net/uid-25266990-id-4080103.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值