sysbench 安装、使用和测试
摘要:
sysbench是一个开源的、模块化的、跨平台的多线程性能测试工具,可以用来进行CPU、内存、磁盘I/O、线程、数据库的性能测试。目前支持的数据库有MySQL、Oracle和PostgreSQL。当前功能允许测试的系统参数有:
file I/O performance (文件I / O性能)
scheduler performance (调度性能)
memory allocation and transfer speed (内存分配和传输速度)
POSIX threads implementation performance (POSIX线程执行绩效)
database server performance (OLTP benchmark) (数据库服务器性能)
安装:
1):Ubuntu系统可以直接apt,如:
apt-get install sysbench
2):其他系统的则可以编译安装[在/home/zhoujy/目录下]:(安装前先装automake,libtool)
wget https://nchc.dl.sourceforge.net/project/sysbench/sysbench/0.4.12/sysbench-0.4.12.tar.gz
tar zxvf sysbench-0.4.12.tar.gz
进入解压目录,并且创建安装目录:
root@m2:/home/zhoujy# cd sysbench-0.4.12/
root@m2:/home/zhoujy/sysbench-0.4.12# mkdir /usr/sysbench/
准备编译
root@m2:/home/zhoujy/sysbench-0.4.12# apt-get install automake
root@m2:/home/zhoujy/sysbench-0.4.12#apt-get install libtool
root@m2:/home/zhoujy/sysbench-0.4.12# ./autogen.sh
要是出现:perl: warning: Falling back to the standard locale ("C")。则需要设置locale:
echo "export LC_ALL=C" >> /root/.bashrc
source /root/.bashrc
要是没有安装开发包,即/usr/include/ 目录下面没有mysql文件夹。则需要执行安装(版本为12.04):
sudo apt-get install libmysqlclient-dev
sudo apt-get install libmysqld-dev
sudo apt-get install libmysqld-pic
执行configure操作:
./configure --prefix=/usr/sysbench/ --with-mysql-includes=/usr/include/mysql/ --with-mysql-libs=/usr/lib/mysql/ --with-mysql
说明:
--prefix=/usr/sysbench/ :指定sysbench的安装目录。
--with-mysql-includes=/usr/include/mysql/ :指定安装mysql时候的includes目录。
--with-mysql-libs=/usr/lib/mysql/ :指定装mysql时候的lib目录。
--with-mysql :sysbench默认支持mysql,如果需要测试oracle或者pgsql则需要制定–with-oracle或者–with-pgsql。
在这里需要先执行:
cp /usr/bin/libtool /home/zhoujy/sysbench-0.4.12/libtool
再make和make install。否者会出现 libtool 报出的 Xsysbench: command not found 错误,则表示编译文件包的libtool版本太低,需要替换。
选项说明(通用):
root@db2:~# sysbench
Missing required command argument.
Usage: #使用方法
sysbench [general-options]... --test=
[test-options]... command
General options: #通用选项
--num-threads=N number of threads to use [1] #创建测试线程的数目。默认为1.
--max-requests=N limit for total number of requests [10000] #请求的最大数目。默认为10000,0代表不限制。
--max-time=N limit for total execution time in seconds [0] #最大执行时间,单位是s。默认是0,不限制。
--forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off] #超过max-time强制中断。默认是off。
--thread-stack-size=SIZE size of stack per thread [32K] #每个线程的堆栈大小。默认是32K。
--init-rng=[on|off] initialize random number generator [off] #在测试开始时是否初始化随机数发生器。默认是off。
--test=STRING test to run #指定测试项目名称。
--debug=[on|off] print more debugging info [off] #是否显示更多的调试信息。默认是off。
--validate=[on|off] perform validation checks where possible [off] #在可能情况下执行验证检查。默认是off。
--help=[on|off] print help and exit #帮助信息。
--version=[on|off] print version and exit #版本信息。
Compiled-in tests: #测试项目
fileio - File I/O test #IO
cpu - CPU performance test #CPU
memory - Memory functions speed test #内存
threads - Threads subsystem performance test #线程
mutex - Mutex performance test #互斥性能测试
oltp - OLTP test # 数据库,事务处理
Commands: prepare:测试前准备工作; run:正式测试 cleanup:测试后删掉测试数据 help version
See 'sysbench --test=
help' for a list of options for each test. #查看每个测试项目的更多选项列表
更多选项:
1):sys