SysBench – 一种系统性能Benchmark
<
div id=”content” contentScore=”3617″>SysBench是一款开源的、跨平台的、模块化的、多线程的性能测试工具,通过高负载地运行在数据库上,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。用于评估操作系统的性能参数。
相关阅读:
SysBench介绍与使用 http://www.linuxidc.com/Linux/2012-11/75054.htm
SysBench 0.4.12安装以及测试 http://www.linuxidc.com/Linux/2011-03/32843.htm
RHEL6 SysBench性能测试 http://www.linuxidc.com/Linux/2012-05/61067.htm
MySQL压力测试工具SysBench 0.4.12的安装 http://www.linuxidc.com/Linux/2011-05/35411.htm
1 sysbench简介
Sysbench使得我们无需采用真正的复杂的数据库benchmark而获取系统的性能概况。
目前主要支持的数据库有mysql、Oracle、postgresql。
可评估的系统性能参数有:
1. Cpu性能
2. 内存分配与传输速度测试
3. 互斥体测试
4. 文件I/O性能
5. 线程调度性能
6. 数据库服务性能(OLTP基准)
本来sysbench主要是为mysql编写的benchmark。但是现在SysBench将进一步扩展,以支持更多的数据库backends,distributed benchmarks和第三方插件模块。
sysbench按照指定的数量开启线程,每个线程与mysql建立一个连接,每个线程不停地进行事务操作,打开事务,然后进行一些查询、更新、插入操作,提交事务,再开始新的事务;所有的sql只访问一个表-sbtest,是由sysbench的prepare命令建好的。其中的记录数,也是在prepare时指定好并创建的。测试结束,会有一个统计结果,包括例如每秒事务数、平均响应时间等等;
2 sysbench下载与安装
1.下载
下载地址:http://sourceforge.net/projects/sysbench/
获得sysbench-0.4.8.tar.gz源码。sysbench-0.4.8.tar.gz编译未通过。
2.安装
默认支持MySQL,如果需要测试Oracle/PostgreSQL,则在configure时需要加上–with-oracle或者–with-pgsql参数
[root@RedHat sysbench-0.4.8]# ./configure –without-mysql
[root@RedHat sysbench-0.4.8]# make
[root@RedHat sysbench-0.4.8]# make install
如果需要测试mysql,则需要配置参数选项:
./configure
–with-mysql-includes=/opt/mysql/include/mysql 表示mysql头文件目录
–with-mysql-libs=/opt/mysql/lib/mysql表示mysql模块目录
如股票缺少libtool请至ftp://ftp.gnu.org/gnu/libtool/下载
3 性能测试与结果分析
请查看sysbench帮助
[root@RedHat sysbench-0.4.8]# sysbench
Missing required command argument.
Usage:
sysbench [general-options]… –test=
General options:
–num-threads=N number of threads to use [1]
–max-requests=N limit for total number of requests [10000]
–max-time=N limit for total execution time in seconds [0]
–thread-stack-size=SIZE size of stack per thread [32K]
–init-rng=[on|off] initialize random number generator [off]
–test=STRING test to run
–debug=[on|off] print more debugging info [off]
–validate=[on|off] perform validation checks where possible [off]
–help=[on|off] print help and exit
Compiled-in tests:
fileio – File I/O test
cpu – CPU performance test
memory – Memory functions speed test
threads – Threads subsystem performance test
mutex – Mutex performance test
oltp – OLTP test
Commands: prepare run cleanup help
See ‘sysbench –test=
[root@RedHat sysbench-0.4.8]#
其中通用参数
参数名 | 参数描述 |
–num-threads=N | 测试时使用的线程数,默认为1 |
–max-requests=N | 请求数最大现在,默认10000 |
-max-time=N | 执行时间最大限制,默认为0 |
–thread-stack-size=SIZE | 每个线程的stack大小,默认是32K |
–init-rng=[on|off] | 是否初始化随机数生成器 |
–test=STRING | 运行的测试 |
–debug=[on|off] | 是否打印更多的debug信息 |
–validate=[on|off] | 是否执行有效性检查 |
–help=[on|off] | 打印帮助并退出 |
其中–test=STRING中的STRING可选项有:
<
table cellspacing=”0″ cellpadding=”0″>