sysbench安装及性能测试
现在的压力测试工具各种各样,只要上手好几款功能强大点的而且比较大众化的压力测试工具即可,以下跟大家交流下sysbench的安装和压力测试
sysbench支持以下几种测试模式:
1、CPU运算性能
2、磁盘IO性能
3、内存分配及传输速度
4、内存分配及传输速度
5、POSIX线程性能
6、数据库性能(OLTP基准测试)
目前sysbench主要支持mysql,drizzle,pgsql,oracle等几种数据库
下面安装sysbench
一、 下载源码包,安装epel包后以便安装bzr客户端:
[root ~]$ rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-tmp.wgHSDP: Header V3 DSA/SHA1 Signature, key ID 217521f6: NOKEY
Preparing... ########################################### [%]
:epel-release ########################################### [%]
然后就可以开始安装bzr客户端了:
以下安装报错了:
[root yum.repos.d]$ yum install bzr
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: mirrors.ustc.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
epel | 3.7 kB :
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bzr.x86_64 :2.1.-.el5 will be installed
--> Processing Dependency: python(abi) = 2.4 for package: bzr-2.1.-.el5.x86_64
--> Processing Dependency: python-paramiko for package: bzr-2.1.-.el5.x86_64
--> Processing Dependency: python-elementtree for package: bzr-2.1.-.el5.x86_64
--> Running transaction check
---> Package bzr.x86_64 :2.1.-.el5 will be installed
--> Processing Dependency: python(abi) = 2.4 for package: bzr-2.1.-.el5.x86_64
--> Processing Dependency: python-elementtree for package: bzr-2.1.-.el5.x86_64
---> Package python-paramiko.noarch :1.7.-.el5 will be installed
--> Processing Dependency: python(abi) = 2.4 for package: python-paramiko-1.7.-.el5.noarch
--> Finished Dependency Resolution
Error: Package: bzr-2.1.-.el5.x86_64 (epel)
Requires: python(abi) = 2.4
Installed: python-2.6.-.el6.x86_64 (@updates)
python(abi) = 2.6
Available: python26-2.6.-.el5.x86_64 (epel)
python(abi) = 2.6
Error: Package: python-paramiko-1.7.-.el5.noarch (epel)
Requires: python(abi) = 2.4
Installed: python-2.6.-.el6.x86_64 (@updates)
python(abi) = 2.6
Available: python26-2.6.-.el5.x86_64 (epel)
python(abi) = 2.6
Error: Package: bzr-2.1.-.el5.x86_64 (epel)
Requires: python-elementtree
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
解决方法把旧版本的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--.noarch conflicts with file from package epel-release--.noarch
file /etc/yum.repos.d/epel.repo from install of epel-release--.noarch conflicts with file from package epel-release--.noarch
二、再安装安装bzr客户端:
[root yum.repos.d]$ yum install bzr -y
.....
.......
Running Transaction
Installing : python-paramiko-1.7.-2.1.el6.noarch /
Installing : bzr-2.1.-.el6.x86_64 /
Installed:
bzr.x86_64 :2.1.-.el6
Dependency Installed:
python-paramiko.noarch :1.7.-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 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./ --with-mysql-includes=/usr/local/mysql-5.5./include/ \
> --with-mysql-libs=/usr/local/mysql-5.5./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.-1.1.tgz
[root sysbench-0.4.-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.-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.-1.1/sysbench
[root sysbench]$ ./sysbench --mysql-host=localhost --mysql-port= --mysql-user=root --mysql-password= --mysql-socket=/data/mysql-5.5/mysql.sock \
> --test=tests/db/oltp.lua --oltp_tables_count= --oltp-table-size= --rand-init=on prepare
若运行过程报以下错:
./sysbench: error while loading shared libraries: libmysqlclient.so.: cannot open shared object file: No such file or directory
解决方法:
ln -s /usr/local/mysql-5.5./lib/libmysqlclient.so. /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:
Report intermediate results every second(s)
Random number generator seed is and will be ignored Threads started!
-- 每10秒钟报告一次测试结果,tps、每秒读、每秒写、%以上的响应时长统计
[ 10s] threads: , tps: 119.03, reads/s: 1677.65, writes/s: 478.93, response time: .40ms (%)
[ 20s] threads: , tps: 76.80, reads/s: 1074.47, writes/s: 307.19, response time: .75ms (%)
[ 30s] threads: , tps: 88.20, reads/s: 1232.94, writes/s: 351.61, response time: .98ms (%)
[ 40s] threads: , tps: 149.79, reads/s: 2099.73, writes/s: 600.78, response time: .18ms (%)
[ 50s] threads: , tps: 78.09, reads/s: 1093.32, writes/s: 312.38, response time: .12ms (%)
[ 60s] threads: , tps: 79.30, reads/s: 1109.76, writes/s: 316.82, response time: .75ms (%)
[ 70s] threads: , tps: 35.50, reads/s: 497.52, writes/s: 142.41, response time: .36ms (%)
[ 80s] threads: , tps: 45.40, reads/s: 635.57, writes/s: 180.39, response time: .67ms (%)
[ 90s] threads: , tps: 73.00, reads/s: 1019.58, writes/s: 290.49, response time: .84ms (%)
[ 100s] threads: , tps: 148.01, reads/s: 2069.14, writes/s: 591.64, response time: .85ms (%)
[ 110s] threads: , tps: 60.60, reads/s: 850.90, writes/s: 242.90, response time: .81ms (%)
[ 120s] threads: , tps: 88.20, reads/s: 1237.71, writes/s: 354.20, response time: .94ms (%)
OLTP test statistics:
queries performed:
read: -- 读总数
write: -- 写总数
other: -- 其他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)
total: -- 全部总数
transactions: (86.74 per sec.) -- 总事务数(每秒事务数)
deadlocks: (0.00 per sec.) -- 发生死锁总数
read/write requests: (1561.37 per sec.) -- 读写总数(每秒读写次数)
other operations: (173.49 per sec.) -- 其他操作总数(每秒其他操作次数) General statistics: -- 一些统计结果
total time: .1714s -- 总耗时
total number of events: -- 共发生多少事务数
total time taken by event execution: .6432s -- 所有事务耗时相加(不考虑并行因素)
response time:
min: .35ms -- 最小耗时
avg: .16ms -- 平均耗时
max: .05ms -- 最长耗时
approx. percentile: .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分钟,否则测试数据可能不具参考意义。
想了解更多关于sysbench的相关说明,可以参考大牛的博客:http://imysql.com/2014/10/17/sysbench-full-user-manual.shtml
|
作者:陆炫志 出处:xuanzhi的博客 http://www.cnblogs.com/xuanzhi201111 您的支持是对博主最大的鼓励,感谢您的认真阅读。本文版权归作者所有,欢迎转载,但请保留该声明。 |
sysbench安装及性能测试的更多相关文章
- Mysql多线程性能测试工具sysbench 安装、使用和测试
From:http://www.cnblogs.com/zhoujinyi/archive/2013/04/19/3029134.html 摘要: sysbench是一个开源的.模块化的.跨 ...
- sysbench——服务器cpu性能测试
一.前言 最近在工作中需要测试cpu占用率.内存占用率,我想要寻找一种合适的能提高cpu占用率的工具及方法.先尝试了使用 echo "scale=5000; 4*a(1)" | b ...
- Sysbench安装步骤及详情
Sysbench安装步骤及详情 Sysbench是压力测试工具,可以测试系统的CPU,内存,I/O等,也可以用于数据库的性能测试 Sysbench安装步骤: 安装具体分为Ubuntu16.04和Cen ...
- sysbench 安装、使用和测试
摘要: sysbench是一个开源的.模块化的.跨平台的多线程性能测试工具,可以用来进行CPU.内存.磁盘I/O.线程.数据库的性能测试.目前支持的数据库有MySQL.Oracle和Post ...
- 给CentOS6.3 + PHP5.3 安装PHP性能测试工具 XHProf-0.9.2
一.什么是XHProf XHProf官网:http://pecl.php.net/package/xhprof XHProf是一个分层PHP性能分析工具.它报告函数级别的请求次数和各种指标,包括 阻塞 ...
- 给Windows + Apache 2.2 + PHP 5.3 安装PHP性能测试工具 xhprof_0.10.3_php53_vc9.dll
1.下载XHProf 到这里 http://dev.freshsite.pl/php-extensions/xhprof.html 下载Windows版本的XHProf,我这里选择下载 XHProf ...
- sysbench 安装
sysbench源代码可以在https://launchpad.net/sysbench找到.也可以从本文件附件中下载. 先安装好mysql,记录下安装目录.默认为 /usr/local/mysql ...
- sysbench安装
sysbench安装 1.下载软件mkdir -p /usr/local/softwarecd /usr/local/softwaregit clone https://github.com/akop ...
- linux sysbench (一): CPU性能测试详解
网上sysbench教材众多,但没有一篇中文教材对cpu测试参数和结果进行详解. 本文旨在能够让读者对sysbench的cpu有一定了解. 小慢哥的原创文章,欢迎转载 1.sysbench基础知识 s ...
随机推荐
- JIRA部署破解和confluence整合
JIRA是一个项目跟踪管理工具,帮助团队创建计划任务.构建并发布优秀的产品.全球成千上万的团队选择JIRA,用JIRA来捕获.组织管理缺陷.分配任务,跟踪团队的活动.不论在桌面PC还是移动终端设备上, ...
- 两种常用文件分享方式 - 网络硬盘快速分享, 点对点的文件共享 BitTorrent Sync
普通的用户经常通过电子邮件.QQ传递等方式进行文件的分享,但是由于不同的网络环境有的时候可能会有不同的限制,所以我们就需要寻找其他的方式来替代.今天就为大家推荐两个既常用又与众不同的分享方式. 中国论 ...
- Eclipse 使用 VS快捷键
这里楼主也是尝试了,只能说一般吧.还是有许多没有改过来... 想要尝试的朋友,可以试试. 首先进入Eclipse 然后 接着 Name:CDT Location:http://download.ecl ...
- Triangle Counting UVA - 11401(递推)
大白书讲的很好.. #include <iostream> #include <cstring> using namespace std; typedef long long ...
- 【BZOJ1228】[SDOI2009]E&D(博弈论)
[BZOJ1228][SDOI2009]E&D(博弈论) 题面 BZOJ 洛谷 题解 这种打表找规律的题目真的不知道可以说什么好啊... #include<iostream> #i ...
- 【转】spi测试自发自收(中断通信方式)
1.初始化spi时钟 void spiRccinit(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2Peri ...
- 51nod 1479 小Y的数论题
一脸不可做题~~~233333 T<=100000,所以一定要logn出解啦. 但是完全没有头绪*&#……%*&……()……#¥*#@ 题解: 因为2^p+2^p=2^(p+1) ...
- ByteBuffer的allocate与allocateDirect2013-01-11
在Java中当我们要对数据进行更底层的操作时,通常是操作数据的字节(byte)形式,这时常常会用到ByteBuffer这样一个类.ByteBuffer提供了两种静态实例方式: public sta ...
- SQL Server 执行计划的理解
要理解执行计划,怎么也得先理解,那各种各样的名词吧.鉴于自己还不是很了解.本文打算作为只写懂的,不懂的懂了才写. 在开头要先说明,第一次看执行计划要注意,SQL Server的执行计划是从右向左看的. ...
- ansible报错Aborting, target uses selinux but python bindings (libselinux-python) aren't installed【转】
报错内容: TASK [activemq : jvm configuration] ********************************************************** ...