2019独角兽企业重金招聘Python工程师标准>>>

Tpcc-mysql是percona基于tpcc衍生出来专用于mysql基准测试的产品,在业界有较高知名度,下面就介绍此工具的使用,及数据结果使用gnuplot绘图。

1,安装 tpcc-mysql:

yum install bzr

bzr branch lp:~percona-dev/perconatools/tpcc-mysql

注:如果yum 找不到bzr 先安装仓库:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

源码拷贝下来后,就需要适当的修改Makefile 否则可能会编译出错而失败,下面红色部分根据实际情况修改

[root@localhost src]# cat Makefile
#
# "make all" to build necessary executables.
#

LIBS=           `mysql_config --libs_r` -lrt

INC=            -I. `mysql_config --include` -I /opt/app/mysql5/include/mysql/

#DEFS=          -DDEBUG

CFLAGS=         -w -O2 -g

TRANSACTIONS=   neword.o payment.o ordstat.o delivery.o slev.o
OBJS=           main.o spt_proc.o driver.o support.o sequence.o rthist.o $(TRANSACTIONS)

.SUFFIXES:
.SUFFIXES: .o .c

.c.o:
        $(CC) $(CFLAGS) $(INC) $(DEFS) -c $*.c

all: ../tpcc_load ../tpcc_start

../tpcc_load : load.o support.o
        $(CC) load.o support.o $(LIBS) -L /opt/app/mysql5/lib/mysql/ -o ../tpcc_load

../tpcc_start : $(OBJS)
        $(CC) $(OBJS) $(LIBS) -L /opt/app/mysql5/lib/mysql/ -o ../tpcc_start

clean :
        rm -f *.o
[root@localhost src]#

安装完毕在根目录下有:

[root@localhost tpcc-mysql]# ls
add_fkey_idx.sql
create_table.sql 
load.sh 
schema2 
src       
tpcc_start
count.sql        
drop_cons.sql    
README  
scripts 
tpcc_load
[root@localhost tpcc-mysql]#
建议多读 README,测试过程写的比较详细

2,测试前准备

1> 首先根据readme 生成测试库
mysql> create database tpcc1000;
mysql> use tpcc1000
mysql> \. /opt/create_table.sql
mysql> \. /opt/add_fkey_idx.sql

2> 生成测试数据

[root@localhost src]#./tpcc_load 192.168.1.2 tpcc1000 nigel "12345" 20

生成测试数据(这步可能需要很长时间,根据机器性能不同而不同)。

3> 测试开始:

下列测试分别对 innodb_buffer_pool_size = 8M,512M,2G 进行测试,事务及实际关系结果下如图1所示:

./tpcc_start -h172.16.0.230 -dtpcc1000 -unigel -p12345 -w20 -c16 -r10 -l1200 > /opt/8m-tpcc-data.log
./tpcc_start -h172.16.0.230 -dtpcc1000 -unigel -p12345 -w20 -c16 -r10 -l1200 > /opt/512m-tpcc-data.log
./tpcc_start -h172.16.0.230 -dtpcc1000 -unigel -p12345 -w20 -c16 -r10 -l1200 > /opt/2g-tpcc-data.log

: -d 测试库
:-u 用户名
:-p 密码
:-w 使用多少个数据仓库
:-c 测试的并发数
:-r 预热几秒
:-l 运行测试多长时间

log内容截取如下:

cat 2g-tpcc-data.txt

***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value '172.16.0.230'
option d with value 'tpcc1000'
option u with value 'nigel'
option p with value '12345'
option w with value '20'
option c with value '16'
option r with value '10'
option l with value '1200'
<Parameters>
     [server]: 192.168.1.2

[port]: 3306
     [DBname]: tpcc1000
       [user]: nigel
       [pass]: 12345
  [warehouse]: 20
 [connection]: 16
     [rampup]: 10 (sec.)
    [measure]: 1200 (sec.)

RAMP-UP TIME.(10 sec.)

MEASURING START.

10, 19(0):2.842|2.860, 13(0):0.492|0.536, 2(0):0.214|0.245, 1(0):0.000|2.713, 0(0):0.000|0.000
  20, 18(0):2.742|2.826, 16(0):0.467|0.482, 1(0):0.000|0.215, 2(0):2.759|2.969, 2(0):7.584|7.773
  30, 19(0):2.646|2.717, 24(0):0.461|0.505, 2(0):0.201|0.224, 2(0):2.527|2.620, 2(0):7.603|7.767
  40, 39(0):1.939|2.287, 32(0):0.512|0.579, 3(0):0.198|0.205, 2(0):2.301|2.985, 5(0):6.314|6.601
  50, 33(0):2.207|2.255, 38(0):0.408|0.484, 4(0):0.203|0.211, 3(0):2.595|2.680, 3(0):5.515|5.698
  60, 44(0):2.050|2.151, 47(0):0.405|0.408, 5(0):0.193|0.221, 5(0):2.530|2.586, 5(0):5.918|6.438
  70, 59(0):2.192|2.212, 54(0):0.395|0.412, 5(0):0.207|0.225, 7(0):2.390|2.447, 5(0):5.680|6.023
  80, 60(0):1.927|1.987, 58(0):0.421|0.461, 7(0):0.203|0.207, 4(0):2.197|2.264, 6(0):5.693|6.001
  90, 64(0):2.104|2.234, 66(0):0.444|0.487, 6(0):0.190|0.210, 6(0):2.422|2.426, 7(0):5.359|6.044
 100, 69(0):2.016|2.152, 68(0):0.415|0.425, 6(0):0.199|0.201, 9(0):2.324|2.355, 7(0):5.568|5.768
 110, 74(0):2.147|2.148, 76(0):0.463|0.482, 8(0):0.218|0.246, 7(0):2.252|2.312, 9(0):5.610|5.769
 120, 88(0):2.162|2.215, 89(0):0.441|0.513, 9(0):0.204|0.216, 9(0):2.208|2.455, 6(0):5.792|6.034
 130, 100(0):1.961|1.981, 101(0):0.433|0.449, 10(0):0.209|0.210, 9(0):2.345|2.355,(0):5.856|5.880
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

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

<Raw Results>
  [0] sc:10874  lt:0  rt:0  fl:0
  [1] sc:10869  lt:0  rt:0  fl:0
  [2] sc:1089  lt:0  rt:0  fl:0
  [3] sc:1086  lt:0  rt:0  fl:0
  [4] sc:1091  lt:0  rt:0  fl:0
 in 1200 sec.

<Raw Results2(sum ver.)>
  [0] sc:10894  lt:0  rt:0  fl:0
  [1] sc:10883  lt:0  rt:0  fl:0
  [2] sc:1089  lt:0  rt:0  fl:0
  [3] sc:1086  lt:0  rt:0  fl:0
  [4] sc:1091  lt:0  rt:0  fl:0

<Constraint Check> (all must be [OK])
 [transaction percentage]
        Payment: 43.46% (>=43.0%) [OK]
   Order-Status: 4.35% (>= 4.0%) [OK]
       Delivery: 4.34% (>= 4.0%) [OK]
    Stock-Level: 4.36% (>= 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]

<TpmC>
                 543.700 TpmC
[root@localhost opt]#

#
#=================================
#
4> 生成测试数据文件:
 
./tpcc_analyze.sh /opt/8m-tpcc-data.log > tpcc-8-data.txt
 ./tpcc_analyze.sh /opt/512m-tpcc-data.log > tpcc-512-data.txt
./tpcc_analyze.sh /opt/2g-tpcc-data.log > tpcc-2g-data.txt

3,使用gnuplot 绘图

1> 合并数据文件,以便于画图:
 
paste tpcc-8-data.txt tpcc-512-data.txt tpcc-2g-data.txt > tpcc-graph-data.txt

2> 使用脚本画图;

./tpcc-graph.sh tpcc-graph-data.txt  201.jpg


                   图:1

4,附脚本:

[root@localhost shell]# cat tpcc_analyze.sh
#!/bin/bash
TIMESLOT=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 ?\n",$1,aggr) ; cntr=0; aggr=0  }  } '

[root@localhost shell]# cat tpcc-graph.sh
#!/bin/bash
gnuplot << EOP
set style line 1 lt 1 lw 3
set style line 2 lt 5 lw 3
set style line 3 lt 9 lw 3
set terminal jpeg size 640,480
set grid x y
set xlabel "Time(sec)"
set ylabel "Transactions"
set output '$2'
plot "$1" title "PS 5.1.56 buffer pool 8M" ls 1 with lines , \
     "$1" us 3:4 title "PS 5.1.56 buffer pool 512M" ls 2 with lines ,\
     "$1" us 5:6 title "PS 5.1.56 buffer pool 2G" ls 3 with lines axes x1y1
EOP
[root@localhost shell]# 
  完。

转载于:https://my.oschina.net/sansom/blog/167175

实战 TPCC-MySQL 基准测试相关推荐

  1. tpcc mysql 基准测试_tpcc mysql 基准测试

    使用tpcc mysql进行基准测试 获取并编译tpcc mysql 获取tpcc mysql 源码 sudo apt-get install bzr bzr branch lp:~percona-d ...

  2. tpcc mysql 基准测试_TPCC-MySQL基准测试

    1.简述 TPCC-MySQL输出结果包括五个业务逻辑,这五个业务逻辑构成了TPCC-MySQL测试的整个事务处理过程.具体如下所示: New-Order:新订单 Payment:支付 Order-S ...

  3. tpcc mysql 基准测试_使用tpcc-mysql 对mysql进行基准测试

    0,安装 bzr 工具(什么是bzr? bzr - easy to use distributed version control system) root@debian6:~# apt-get in ...

  4. 实战部署MySQL用户认证的Postfix邮件系统(3)

    实战部署Postfix+MySQL+Dovecot+Postfixadmin+Extmail邮件系统(3) -----构建开源邮件系统系列 如果您对本系列文章感兴趣,可以通过点击以下链接查看全文: 点 ...

  5. mysql 连接查询_Swoole 实战:MySQL 查询器的实现(协程连接池)

    Swoole 实战:MySQL 查询器的实现(协程连接池) 需求分析 本篇我们将通过 Swoole 实现一个自带连接池的 MySQL 查询器: 1. 支持通过链式调用构造并执行 SQL 语句: 2. ...

  6. shell编程系列23--shell操作数据库实战之mysql命令参数详解

    shell编程系列23--shell操作数据库实战之mysql命令参数详解mysql命令参数详解-u 用户名-p 用户密码-h 服务器ip地址-D 连接的数据库-N 不输出列信息-B 使用tab键代替 ...

  7. 详解 MySQL 基准测试和 sysbench 工具

    前 言 作为一名后台开发,对数据库进行基准测试,以掌握数据库的性能情况是非常必要的.本文介绍了MySQL基准测试的基本概念,以及使用sysbench对MySQL进行基准测试的详细方法. 文章有疏漏之处 ...

  8. 企业实战|Mysql不停机维护主从同步

    转载来源 :企业实战|Mysql不停机维护主从同步 : https://mp.weixin.qq.com/s/CQFmFhtRMFsESofDpTOvUA 实战环境: Mysql-5.7 Xtraba ...

  9. 学习笔记3:Mysql基准测试

    Mysql基准测试:     [什么是基准测试]:基准测试是一种测量和评估软件性能指标的活动,用于建立某个时刻的性能基准,                         以便系统发生软硬件变化时重新 ...

  10. 《高性能MySQL》——MySQL基准测试(笔记)

    文章目录 二.MySQL基准测试 2.1 为什么需要基准测试 2.2 基准测试的策略 2.2.1 测试何种指标 2.3 基准测试方法 2.3.1设计和规划基准测试 2.3.2 基准测试应该运行多长时间 ...

最新文章

  1. OpenCV实现图像颜色特征提取
  2. CTFshow 命令执行 web46
  3. boost::fibers::barrier用法的测试程序
  4. [导入]毕业的大学生的100条忠告
  5. 计算TPCC值的例子
  6. Android的内存分配与回收
  7. SAP 电商云 Spartacus UI 的交货模式 Delivery Mode 设计
  8. python人脸关键点识别_用Face++实现人脸关键点检测
  9. iOS 利用UIDocumentInteractionController打开和预览文档
  10. 前端开发发展简史-个人经验分享
  11. word2003流程图变成图片_流程图怎么画word2003
  12. MAC 下如何更改brew源地址
  13. Java中多态的表现形式
  14. Rabbit的字符串
  15. java validate 框架_使用validate验证框架
  16. 惊闻!港媒:中国首艘航母海试时间延后1个月(图)
  17. break跳出两个嵌套的for循环
  18. Json2:使用gson解析为List和Map
  19. 12306余票查询(五)——网页模板制作
  20. SecureCRT_Python笔记

热门文章

  1. smarty 模板不能正常加载css,js的问题
  2. 转载于:http://blog.csdn.net/iorikyo/article/details/1314892
  3. 刷新后保持大分类和小分类的展开状态
  4. 如何在DNN4下使用VS2005进行单元测试???
  5. 【bzoj1022】[SHOI2008]小约翰的游戏John 博弈论
  6. Spring设置定时器配置
  7. zzulioj--1711--漂洋过海来看你(dfs+vector)
  8. 网络之美:JavaScript中Get和Set访问器的实现
  9. Django index_together设置
  10. Spring Cloud Alibaba系列教程-03-搭建生产可用的Nacos集群