SYSBENCH 安装、使用和测试
2013-09-30 14:18
423 查看
/article/5123947.html
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 http://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-name> [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=<name> help' for a list of options for each test. #查看每个测试项目的更多选项列表
更多选项:
1):sysbench --test=fileio help
View
Code
2):sysbench --test=cpu help
View
Code
3):sysbench --test=memory help
View
Code
4):sysbench --test=threads help
View
Code
5):sysbench --test=mutex help
View
Code
6): sysbench --test=oltp help
root@db2:~# sysbench --test=oltp help sysbench 0.4.12: multi-threaded system evaluation benchmark oltp options: --oltp-test-mode=STRING 执行模式{simple,complex(advanced transactional),nontrx(non-transactional),sp}。默认是complex --oltp-reconnect-mode=STRING 重新连接模式{session(不使用重新连接。每个线程断开只在测试结束),transaction(在每次事务结束后重新连接),query(在每个SQL语句执行完重新连接),random(对于每个事务随机选择以上重新连接模式)}。默认是session --oltp-sp-name=STRING 存储过程的名称。默认为空 --oltp-read-only=[on|off] 只读模式。Update,delete,insert语句不可执行。默认是off --oltp-skip-trx=[on|off] 省略begin/commit语句。默认是off --oltp-range-size=N 查询范围。默认是100 --oltp-point-selects=N number of point selects [10] --oltp-simple-ranges=N number of simple ranges [1] --oltp-sum-ranges=N number of sum ranges [1] --oltp-order-ranges=N number of ordered ranges [1] --oltp-distinct-ranges=N number of distinct ranges [1] --oltp-index-updates=N number of index update [1] --oltp-non-index-updates=N number of non-index updates [1] --oltp-nontrx-mode=STRING 查询类型对于非事务执行模式{select, update_key, update_nokey, insert, delete} [select] --oltp-auto-inc=[on|off] AUTO_INCREMENT是否开启。默认是on --oltp-connect-delay=N 在多少微秒后连接数据库。默认是10000 --oltp-user-delay-min=N 每个请求最短等待时间。单位是ms。默认是0 --oltp-user-delay-max=N 每个请求最长等待时间。单位是ms。默认是0 --oltp-table-name=STRING 测试时使用到的表名。默认是sbtest --oltp-table-size=N 测试表的记录数。默认是10000 --oltp-dist-type=STRING 分布的随机数{uniform(均匀分布),Gaussian(高斯分布),special(空间分布)}。默认是special --oltp-dist-iter=N 产生数的迭代次数。默认是12 --oltp-dist-pct=N 值的百分比被视为'special' (for special distribution)。默认是1 --oltp-dist-res=N ‘special’的百分比值。默认是75 General database options: --db-driver=STRING 指定数据库驱动程序('help' to get list of available drivers) --db-ps-mode=STRING编制报表使用模式{auto, disable} [auto] Compiled-in database drivers: mysql - MySQL driver mysql options: --mysql-host=[LIST,...] MySQL server host [localhost] --mysql-port=N MySQL server port [3306] --mysql-socket=STRING MySQL socket --mysql-user=STRING MySQL user [sbtest] --mysql-password=STRING MySQL password [] --mysql-db=STRING MySQL database name [sbtest] --mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb] --mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto] --mysql-ssl=[on|off] use SSL connections, if available in the client library [off] --myisam-max-rows=N max-rows parameter for MyISAM tables [1000000] --mysql-create-options=STRING additional options passed to CREATE TABLE []
测试:
1)测试CPU: sysbench --test=cpu --cpu-max-prime=2000 run
View
Code
2)测试线程:sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
View
Code
3)测试IO:--num-threads 开启的线程 --file-total-size 总的文件大小
1,prepare阶段,生成需要的测试文件,完成后会在当前目录下生成很多小文件。
sysbench --test=fileio --num-threads=16 --file-total-size=2G --file-test-mode=rndrw prepare
2,run阶段
sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw run
3,清理测试时生成的文件
sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw cleanup
View
Code
4)测试内存:sysbench --test=memory --memory-block-size=8k --memory-total-size=1G run
View
Code
5)测试mutex:sysbench –test=mutex –num-threads=100 –mutex-num=1000 –mutex-locks=100000 –mutex-loops=10000 run
View
Code
6)测试OLTP:
1,prepare阶段,生成需要的测试表
sysbench --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.X.X --mysql-db=test --oltp-table-size=500000 --mysql-user=root --mysql-password=123456 prepare
2,run阶段
sysbench --num-threads=16 --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=test --oltp-table-size=500000 --mysql-user=root --mysql-password=123456 run
3,清理测试时生成的测试表
sysbench --num-threads=16 --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=test --oltp-table-size=500000 --mysql-user=root --mysql-password=123456 cleanup
root@db2:~# sysbench --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=rep_test --oltp-table-size=1000000 --mysql-user=root --mysql-password=123456 prepare sysbench 0.4.12: multi-threaded system evaluation benchmark No DB drivers specified, using mysql Creating table 'sbtest'... Creating 1000000 records in table 'sbtest'... root@db2:~# sysbench --num-threads=16 --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=rep_test --oltp-table-size=1000000 --mysql-user=root --mysql-password=123456 run sysbench 0.4.12: multi-threaded system evaluation benchmark No DB drivers specified, using mysql Running the test with following options: Number of threads: 16 Doing OLTP test. Running mixed OLTP test Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases) Using "BEGIN" for starting transactions Using auto_inc on the id column Maximum number of requests for OLTP test is limited to 10000 Threads started! Done. OLTP test statistics: queries performed: read: 140000 write: 50000 other: 20000 total: 210000
#—-事务数总计,每秒的事务处理量 transactions: 10000 (356.98 per sec.) deadlocks: 0 (0.00 per sec.) read/write requests: 190000 (6782.56 per sec.) other operations: 20000 (713.95 per sec.) Test execution summary: total time: 28.0130s total number of events: 10000 total time taken by event execution: 447.7731 per-request statistics: min: 3.91ms avg: 44.78ms max: 207.61ms approx. 95 percentile: 76.48ms Threads fairness: events (avg/stddev): 625.0000/22.96 execution time (avg/stddev): 27.9858/0.01 root@db2:~# sysbench --num-threads=16 --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=rep_test --oltp-table-size=1000000 --mysql-user=root --mysql-password=123456 cleanup sysbench 0.4.12: multi-threaded system evaluation benchmark No DB drivers specified, using mysql Dropping table 'sbtest'... Done.
测试表信息:
mysql> desc sbtest; +-------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | k | int(10) unsigned | NO | MUL | 0 | | | c | char(120) | NO | | | | | pad | char(60) | NO | | | | +-------+------------------+------+-----+---------+----------------+ 4 rows in set (0.01 sec) mysql> show create table sbtest\G; *************************** 1. row *************************** Table: sbtest Create Table: CREATE TABLE `sbtest` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=1000001 DEFAULT CHARSET=utf8 1 row in set (0.01 sec) ERROR: No query specified mysql> select count(*) from sbtest; +----------+ | count(*) | +----------+ | 1000000 | +----------+ 1 row in set (0.30 sec) mysql> desc sbtest; ERROR 1146 (42S02): Table 'rep_test.sbtest' doesn't exist
可以用这个测试:
sysbench --num-threads=4 --test=oltp --oltp-reconnect-mode=random --mysql-table-engine=innodb --mysql-host=192.168.200.201 --mysql-db=rep_test --ol tp-table-size=500000 --mysql-user=zjy --mysql-password=yuentadPas8quep#
其他: http://hidba.org/?p=229
http://hi.baidu.com/ancen_ye/item/4b1f33f2d366135fc8f33712
相关文章推荐
- sysbench 测试工具安装使用
- sysbench 安装、使用和测试
- sysbench压力测试工具的安装和使用(2)
- sysbench压力测试工具的安装和使用 (1)
- Mysql 性能测试工具 sysbench的安装和使用
- 基准测试工具sysbench安装和使用
- sysbench 安装、使用和测试
- sysbench 测试工具的安装和使用
- mysql 基准测试 sysbench的安装及基本使用方法
- 使用sysbench对Oracle做基准测试(-) 安装篇
- sysbench 安装,使用和测试
- Mysql多线程性能测试工具sysbench 安装、使用和测试
- sysbench的安装和使用
- caffe--没有安装任何接口的情况下使用shell命令运行mnist并测试手写图像
- SIP压力测试最好的工具,SIPp的安装与使用 (第三章)
- pngcrush安装及使用测试
- 网站压力测试工具webbench简介、安装、使用
- Linux下网站压力测试工具webbench下载安装使用