Sysbench安装及性能测试
作者:网络转载 发布时间:[ 2015/1/26 13:59:53 ] 推荐标签:Sysbench 性能测试
解决方法把旧版本的epel源删除,使用新的:(这个坑说白了,下载的epel源要跟自己使用系统符合,例如你用的是32位系统和64位的系统,下载epel源是不同的)
[root ~]$ cd /etc/yum.repos.d/
[root yum.repos.d]$ ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo epel.repo epel-testing.repo
[root yum.repos.d]$ rm -rf epel.repo
[root yum.repos.d]$ rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.eyCDYb: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### []
file /etc/yum.repos.d/epel-testing.repo from install of epel-release-6-8.noarch conflicts with file from package epel-release-5-4.noarch
file /etc/yum.repos.d/epel.repo from install of epel-release-6-8.noarch conflicts with file from package epel-release-5-4.noarch
|
二、再安装安装bzr客户端:
[root yum.repos.d]$ yum install bzr -y
.....
.......
Running Transaction
Installing : python-paramiko-1.7.5-2.1.el6.noarch 1/2
Installing : bzr-2.1.1-2.el6.x86_64 2/2
Installed:
bzr.x86_64 0:2.1.1-2.el6
Dependency Installed:
python-paramiko.noarch 0:1.7.5-2.1.el6
Complete!
|
之后可以用bzr客户端下载sysbench源码了。
[root ~]$ bzr branch lp:sysbench
You have not informed bzr of your Launchpad ID, and you must do this to
write to Launchpad or access private data. See "bzr help launchpad-login".
Branched 128 revision(s).
[root ~]$ ll -d /root/sysbench/
drwxr-xr-x 7 root root 4096 11月 25 14:45 /root/sysbench/
可以看到,已经下载好sysbench目录了
三、 以下准备安装sysbench,涉及到sysbench源码的配置和编译,首先确认系统安装了gcc gcc-c++编译器:
[root sysbench]$ yum install autoconf automake libtool make cmake gcc gcc-c++ gcc4 -y
[root sysbench]$ pwd
/root/sysbench
[root sysbench]$ ./autogen.sh
查看./counfiure支持的选项再进行编译安装:
[root sysbench]$ ./configure --help | grep with | grep mysql
--with-mysql compile with MySQL support (default is enabled)
--with-mysql-includes path to MySQL header files
--with-mysql-libs path to MySQL libraries
[root sysbench]$ ./configure --with-mysql=/usr/local/mysql-5.5.40/ --with-mysql-includes=/usr/local/mysql-5.5.40/include/
> --with-mysql-includes=/usr/local/mysql-5.5.40/include/
> --with-mysql-libs =/usr/local/mysql-5.5.40/lib/
[root sysbench]$ make && make insall
第二种安装方法:
在 http://sourceforge.net/projects/sysbench 下载sysbench的源码包。
也可以在大牛的MySQL中文网上下载:http://imysql.com/wp-content/uploads/2014/09/sysbench-0.4.12-1.1.tgz
[root src]$wget http://imysql.com/wp-content/uploads/2014/09/sysbench-0.4.12-1.1.tgz
[root src]$ tar zxf sysbench-0.4.12-1.1.tgz
[root sysbench-0.4.12-1.1]$ ls
aclocal.m4 autom4te.cache config config.status configure.ac doc libtool Makefile Makefile.in mkinstalldirs README-WIN.txt TODO
autogen.sh ChangeLog config.log configure COPYING install-sh m4 Makefile.am missing README sysbench
[root sysbench-0.4.12-1.1]$ ./autogen.sh
[root sysbench-0.4.12-1.1]$./configure --with-mysql=/usr/local/mysql-5.5.40/ --with-mysql-includes=/usr/local/mysql-5.5.40/include/
> --with-mysql-libs =/usr/local/mysql-5.5.40/lib/
[root sysbench]$ make && make insall
|
以上的安装只是下载方式不同,安装都是一样的^.^
四、下面进行使用说明:
测试磁盘IOPS可以分为:prepare、run、cleanup三个阶段:(准备数据、运行压测、清理数据)
创建测试数据库:
mysql> create database sbtest;
Query OK, 1 row affected (0.08 sec)
mysql>
[root sysbench]$ pwd
/root/sysbench-0.4.12-1.1/sysbench
[root sysbench]$ ./sysbench --mysql-host=localhost --mysql-port=3308 --mysql-user=root --mysql-password=123456 --mysql-socket=/data/mysql-5.5/mysql.sock
> --test=tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=50000 --rand-init=on prepare
若运行过程报以下错:
./sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
解决方法:
ln -s /usr/local/mysql-5.5.40/lib/libmysqlclient.so.18 /usr/lib64/
关于这几个参数的解释:
--test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试
--oltp_tables_count=10 表示会生成 10 个测试表
--oltp-table-size=50000 表示每个测试表填充数据量为 50000
--rand-init=on 表示每个测试表都是用随机数据来填充的
五、进行OLTP测试
./sysbench --mysql-host=localhost --mysql-port=3308 --mysql-user=root --mysql-password=123456 --mysql-socket=/data/mysql-5.5/mysql.sock
> --test=tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=50000 --num-threads=8
> --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=5 --max-requests=0 --percentile=99 run
参数解释:
--num-threads=8 表示发起 8个并发连接
--oltp-read-only=off 表示不要进行只读测试,也是会采用读写混合模式测试
--report-interval=10 表示每10秒输出一次测试进度报告
--rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
--max-time=120 表示大执行时长为 120秒
--max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定大执行时长
--percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取大值
六、结果解读:
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 8
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
Threads started!
-- 每10秒钟报告一次测试结果,tps、每秒读、每秒写、99%以上的响应时长统计
[ 10s] threads: 8, tps: 119.03, reads/s: 1677.65, writes/s: 478.93, response time: 294.40ms (99%)
[ 20s] threads: 8, tps: 76.80, reads/s: 1074.47, writes/s: 307.19, response time: 495.75ms (99%)
[ 30s] threads: 8, tps: 88.20, reads/s: 1232.94, writes/s: 351.61, response time: 503.98ms (99%)
[ 40s] threads: 8, tps: 149.79, reads/s: 2099.73, writes/s: 600.78, response time: 396.18ms (99%)
[ 50s] threads: 8, tps: 78.09, reads/s: 1093.32, writes/s: 312.38, response time: 758.12ms (99%)
[ 60s] threads: 8, tps: 79.30, reads/s: 1109.76, writes/s: 316.82, response time: 509.75ms (99%)
[ 70s] threads: 8, tps: 35.50, reads/s: 497.52, writes/s: 142.41, response time: 956.36ms (99%)
[ 80s] threads: 8, tps: 45.40, reads/s: 635.57, writes/s: 180.39, response time: 895.67ms (99%)
[ 90s] threads: 8, tps: 73.00, reads/s: 1019.58, writes/s: 290.49, response time: 693.84ms (99%)
[ 100s] threads: 8, tps: 148.01, reads/s: 2069.14, writes/s: 591.64, response time: 472.85ms (99%)
[ 110s] threads: 8, tps: 60.60, reads/s: 850.90, writes/s: 242.90, response time: 1052.81ms (99%)
[ 120s] threads: 8, tps: 88.20, reads/s: 1237.71, writes/s: 354.20, response time: 592.94ms (99%)
OLTP test statistics:
queries performed:
read: 145936 -- 读总数
write: 41696 -- 写总数
other: 20848 -- 其他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)
total: 208480 -- 全部总数
transactions: 10424 (86.74 per sec.) -- 总事务数(每秒事务数)
deadlocks: 0 (0.00 per sec.) -- 发生死锁总数
read/write requests: 187632 (1561.37 per sec.) -- 读写总数(每秒读写次数)
other operations: 20848 (173.49 per sec.) -- 其他操作总数(每秒其他操作次数)
General statistics: -- 一些统计结果
total time: 120.1714s -- 总耗时
total number of events: 10424 -- 共发生多少事务数
total time taken by event execution: 960.6432s -- 所有事务耗时相加(不考虑并行因素)
response time:
min: 5.35ms -- 小耗时
avg: 92.16ms -- 平均耗时
max: 3955.05ms -- 长耗时
approx. 99 percentile: 649.23ms -- 超过99%平均耗时
Threads fairness:
events (avg/stddev): 1303.0000/24.81
execution time (avg/stddev): 120.0804/0.00
|
测试建议:
1、真实测试场景中,数据表建议不低于10个,单表数据量不低于500万行,当然了,要视服务器硬件配置而定。如果是配备了SSD或者PCIE SSD这种高IOPS设备的话,则建议单表数据量少不低于1亿行。
2、真实测试场景中,建议持续压测时长不小于30分钟,否则测试数据可能不具参考意义。
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11