mysql压力测试

一.
tpcc-mysql 测试mysql数据库

1.下载tpcc-mysql

yum install bzr

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

2.编译安装

cd src/

因为tpcc-mysql需要使用mysql的函数库,所以把自己安装目录下的mysql环境变量设给src

export C_INCLUDE_PATH=/usr/local/mysql/include/

export PATH=/usr/local/mysql/bin:$PATH

export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/mysql/lib64:$LD_LIBRARY_PATH

设置完成后直接make,产生两个目录

-rwxr-xr-x 1 root root  60329 Jan 22 16:22 tpcc_load
-rwxr-xr-x 1 root root 154128 Jan 22 16:22 tpcc_start

3压力测试

1现在数据库中建立tpcc_mysql库

create database tpcc_mysql;

2.cd tpcc_mysql 进入tpcc_mysql目录,将tpcc_mysql目录下的建表语句导入

mysql -uroot -pfuture -h127.0.0.1 tpcc_mysql < create_table.sql
3.然后将表的关联关系,外键等加入数据库中

mysql -uroot -pfuture -h127.0.0.1 tpcc_mysql < add_fkey_idx.sql 

4.导入数据

使用tpcc_load导入造的数据,大概10M

./tpcc_load 127.0.0.1:3306 tpcc_mysql root "future" 1

ip:端口 数据库 用户 密码 warehouse为1
5.压测数据

./tpcc_start -h 127.0.0.1 -d tpcc_mysql -u root -p future -w 1 -c 16 -r 1 -l 20 >> /tmp/result.txt

-r 1 表示预热,启动cpu等准备工作

-l 20 表示测试时长为20秒

6.vim /tmp/result.txt 查看测试结果

具体参数内容参考:http://blog.chinaunix.net/uid-26896862-id-3563600.html

<TpmC>
                 528.000 TpmC  每分钟数据库执行的事物是528条





你可能感兴趣的:(mysql压力测试)