本测试针对300个warehouse加载数据,对并发100,200,300进行压测。 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./pub/epel/5/i386/epel-release-5-4.noarch.rpm 源码拷贝下来后,就需要适当的修改Makefile 否则可能会编译出错而失败,下面红色部分根据实际情况修改 [root@localhost src]# cd tpcc-mysql/src/ [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 如果安装失败,需要重新调试,请执行make clean; [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.13 tpcc300 nigel "12345" 300 生成测试数据(300个warehouse基本需要3个小时+,生成的数据文件大概是30G)。 3> 测试开始: 下列测试分别对 innodb_buffer_pool_size = 8M,512M,2G 进行测试,事务及实际关系结果下如图1所示: ./tpcc_start -h172.16.0.230 -dtpcc300 -uroot -p12345 -w300 -c100 -r60 -l1200 > /opt/tpcc-20.log
./tpcc_start -h172.16.0.230 -dtpcc300 -uroot -p12345 -w300 -c100 -r60 -l1200 > /opt/tpcc-50.log
: -d 测试库 :-u 用户名 :-p 密码 :-w 使用多少个数据仓库 :-c 测试的并发数 :-r 预热几秒 :-l 运行测试多长时间 C:> /tpcc_start -h172.16.0.230 -dtpcc300 -uroot -p12345 -w300 -c100 -r60 -l1200 > /opt/tpcc-100.log ![]() [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 绘图失败: 主要就是下载msttcore-fonts-2.0-3.noarch.rpm,linux上安装,再地址放在环境变量 下载地址:http://www./en/images/stories/fedora12/ 具体解决方法:http://blog.csdn.net/zhangskd/article/details/9032769 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
|
|
来自: 王老虎888 > 《mysql实际应用》