测试工具之sysbench安装测试过程
白羽 2018-06-21 来源 :网络 阅读 1328 评论 0

摘要:本文将带你了解测试工具之sysbench安装测试过程,希望本文对大家学测试工具有所帮助。




下面为安装测试的整个过程:

1.下载sysbench://sourceforge.net/projects/sysbench/
2.解压安装包:sysbench-0.4.12.tar.gz出现sysbench-0.4.12文件
tar zxvf sysbench-0.4.12.tar.gz
3.安装:
A.cd  sysbench-0.4.12
B.运行autogen.sh
./autogen.sh
C.安装
./configure –prefix=/home/mysql/xuancan/sysbench \
–with-mysql-includes=/u01/mysql/include/mysql \
–with-mysql-libs=/u01/mysql/lib/mysqlu
–with-mysql
D.make
E.make install
说明:
–prefix=/home/mysql/xuancan/sysbench :指定sysbench的bin目录;
–with-mysql-includes=/u01/mysql/include/mysql :指定安装mysql时候的includes目录;
–with-mysql-libs=/u01/mysql/lib/mysql:指定装mysql时候的lib目录;
–with-mysql:sysbench默认支持mysql,如果需要测试oracle或者pgsql则需要制定–with-oracle或者–with-pgsql
F.
cd /home/mysql/xuancan/sysbench/bin
$sysbench
Missing required command argument.
Usage:
sysbench [general-options]… –test=[test-options]… command
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]
–forced-shutdown=STRING   amount of time to wait after –max-time before forcing shutdown [off]
–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
–version=[on|off]         print version 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 version
See ‘sysbench –test=help’ for a list of options for each test.
安装的时候相关问题与解决办法
drv_mysql.c:35:19: 错误:mysql.h:没有那个文件或目录
drv_mysql.c:36:26: 错误:mysqld_error.h:没有那个文件或目录
drv_mysql.c: In function ‘mysql_drv_describe’:
drv_mysql.c:284: 错误:‘MYSQL_RES’ 未声明 (在此函数内第一次使用)
出现这个错误是没有指定相应的–with-mysql-includes和–with-mysql-libs目录.找到正确的目录从新编译。
make的时候出现
../libtool: line 2412: Xsysbench: command not found
../libtool: line 2547: X-lmysqlclient_r: command not found
../libtool: line 2547: X-lz: command not found
../libtool: line 2547: X-lcrypt: command not found
只要先运行一次./autogen.sh,然后再configure,make就可以了.autogen.sh文件在sysbench-4.12解压目录下的.
4.测试:
A.cpu:sysbench采用寻找最大素数的方式来测试CPU的性能
—->cat /proc/cpuinfo:
model name      : Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz
processor       : 7
cache size      : 6144 KB
address sizes   : 38 bits physical, 48 bits virtual
bogomips        : 4987.59
$sysbench –test=cpu –cpu-max-prime=2000 run
Maximum prime number checked in CPU test: 2000
Test execution summary:
total time:                          1.4765s
total number of events:              10000
total time taken by event execution: 1.4695
per-request statistics:
min:                                  0.14ms
avg:                                  0.15ms
max:                                  0.21ms
approx.  95 percentile:               0.15ms
Threads fairness:
events (avg/stddev):           10000.0000/0.00
execution time (avg/stddev):   1.4695/0.00
—>$cat /proc/cpuinfo
model name      : Intel(R) Xeon(R) CPU           E5320  @ 1.86GHz
processor       : 7
cache size      : 4096 KB
bogomips        : 3733.47
$./sysbench –test=cpu –cpu-max-prime=2000 run
Maximum prime number checked in CPU test: 2000
Test execution summary:
total time:                          3.1066s
total number of events:              10000
total time taken by event execution: 3.1030
per-request statistics:
min:                                  0.30ms
avg:                                  0.31ms
max:                                  0.81ms
approx.  95 percentile:               0.36ms
Threads fairness:
events (avg/stddev):           10000.0000/0.00
execution time (avg/stddev):   3.1030/0.00
B.线程测试:测试线程调度程序的性能
$sysbench –test=threads –num-threads=500 –thread-yields=100 –thread-locks=4 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Test execution summary:
total time:                          2.2713s
total number of events:              10000
total time taken by event execution: 1117.0686
per-request statistics:
min:                                  0.03ms
avg:                                111.71ms
max:                                866.85ms
approx.  95 percentile:             340.09ms
Threads fairness:
events (avg/stddev):           20.0000/4.54
execution time (avg/stddev):   2.2341/0.02
C.文件io测试:fileio基准测试在不同类型的i/o负载下的处理能力,这对不同的raid卡和raid模式很有帮助;
(1)首先生成需要的测试文件,文件总大小300M,100个并发线程,随机读写模式。执行完后会在当前目录下生成一堆小文件:prepare
文件的大小:测试文件的大小应该大于内存,如果测试数据过小,内存缓存文件数据,则不能表示为一种i/o密集型的工作负载;
测试模式:rndrw:合并的随机读写
rndwr:随机写入
rndrd:随机读取
seqrewr:顺序重写
seqwr:顺序写
$sysbench –test=fileio –num-threads=100 –file-total-size=5G–file-test-mode=rndrw prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark
128 files, 40960Kb each, 5120Mb total
Creating files for the test…
(2).执行测试:run
sysbench –test=fileio –num-threads=100 –file-total-size=5G –file-test-mode=rndrw run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 100
Extra file open flags: 0
128 files, 40Mb each
5Gb total file size
Block size 16Kb
Number of random requests for random IO: 10000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
Done.
Operations performed:  6042 Read, 3962 Write, 12428 Other = 22432 Total
Read 94.406Mb  Written 61.906Mb  Total transferred 156.31Mb  (30.785Mb/sec)
1970.22 Requests/sec executed
Test execution summary:
total time:                          5.0776s
total number of events:              10004
total time taken by event execution: 427.4888
per-request statistics:
min:                                  0.01ms
avg:                                 42.73ms
max:                               1409.82ms
approx.  95 percentile:             169.47ms
Threads fairness:
events (avg/stddev):           100.0400/12.98
execution time (avg/stddev):   4.2749/0.43
i/o子系统调整的主要信息:每秒的请求数量和总体的吞吐量:每秒1970.22 个请求,每秒30.785Mb传输量。
(3).将生成的文件删除:
$sysbench –test=fileio –num-threads=100 –file-total-size=5G –file-test-mode=rndrw cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark
D.mutex测试:测mutex的性能
$sysbench –test=mutex –num-threads=100 –mutex-num=1000 –mutex-locks=100000 –mutex-loops=10000 run
Test execution summary:
total time:                          12.5606s
total number of events:              100
total time taken by event execution: 1164.4236
per-request statistics:
min:                               9551.87ms
avg:                              11644.24ms
max:                              12525.32ms
approx.  95 percentile:           12326.25ms
Threads fairness:
events (avg/stddev):           1.0000/0.00
execution time (avg/stddev):   11.6442/0.59
E。内存测试:测试内存的连续写性能
$sysbench –test=memory –num-threads=100 –memory-block-size=8192 –memory-total-size=10G run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Operations performed: 1310720 (396525.32 ops/sec)
10240.00 MB transferred (3097.85 MB/sec)
Test execution summary:
total time:                          3.3055s
total number of events:              1310720
total time taken by event execution: 205.0560
per-request statistics:
min:                                  0.00ms
avg:                                  0.16ms
max:                               1066.04ms
approx.  95 percentile:               0.02ms
Threads fairness:
events (avg/stddev):           13107.2000/3870.38
execution time (avg/stddev):   2.0506/0.28
F。mysql数据库测试:
(1).首先需要创建默认的sbtest数据库,或者使用–mysql-db指定一个已经存在的数据库
root@(none) 10:51:42>create database sbtest;
Query OK, 1 row affected (0.01 sec)
(2).生成测试数据,引擎为innodb,表大小为1000000条记录
$sysbench –test=oltp –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-socket=/u01/mysql/run/mysql.sock prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
Creating table ‘sbtest’…
Creating 5000000 records in table ‘sbtest’…
(3).查看生成的表:
root@sbtest 10:52:43>use sbtest
Database changed
root@sbtest 10:54:58>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)
(4).测试:
[MM-Writable@dev031033.sqa.cm4 ~/xuancan/sysbench/bin]
$sysbench –test=oltp –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-socket=/u01/mysql/run/mysql.sock run
—–200*5000000=1G
OLTP test statistics:
queries performed:
read:                            140000
write:                           50000
other:                           20000
total:                           210000
transactions:                        10000  (324.49 per sec.)
deadlocks:                           0      (0.00 per sec.)
read/write requests:                 190000 (6165.29 per sec.)
other operations:                    20000  (648.98 per sec.)
—-事务数总计,每秒的事务处理量
Test execution summary:
total time:                          30.8177s
total number of events:              10000
total time taken by event execution: 30.7415
per-request statistics:
min:                                  2.15ms
avg:                                  3.07ms
max:                                 56.70ms
approx.  95 percentile:               3.44ms
—每个请求的统计信息
Threads fairness:—-线程权重信息,工作负荷如何被均匀分配
events (avg/stddev):           10000.0000/0.00
execution time (avg/stddev):   30.7415/0.00
(5).清理数据:
[MM-Writable@dev031033.sqa.cm4 ~/xuancan/sysbench/bin]
$sysbench –test=oltp –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-socket=/u01/mysql/run/mysql.sock cleanup


本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标软件测试之测试工具频道!


本文由 @白羽 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程