Sysbench基准测试

Sysbench和TPCC-MySQL一样,也是一款基准测试的工具。

TPCC-MySQL
http://blog.itpub.net/29254281/viewspace-1195589/

相对于TPCC-MySQL,Sysbench不仅可以对MySQL,也可以对Oracle,PostgreSQL进行基准测试。

源码下载地址:
https://launchpad.net/sysbench

先下载依赖包
yum install automake autoconf -y

运行./configure && make 命令,可能有以下的报错
../libtool: line 5172: : command not found
修改configure.ac文件


将LIBTOOL注释,并增加AC_PROG_RANLIB


修改之后运行如下命令
./autogen.sh && ./configure && make
完成之后,进入sysbench文件夹,可以看到sysbench命令已经编译完成。

1.进行文件IO测试
准备文件

进行基准测试
  1. [root@mysql1 sysbench]# ./sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrw --file-num=16 --num-threads=16 run
  2. sysbench 0.4.12: multi-threaded system evaluation benchmark
  3. Running the test with following options:
  4. Number of threads: 16
  5. Extra file open flags: 0
  6. 16 files, 128Mb each
  7. 2Gb total file size
  8. Block size 16Kb
  9. Number of random requests for random IO: 10000
  10. Read/Write ratio for combined random IO test: 1.50
  11. Periodic FSYNC enabled, calling fsync() each 100 requests.
  12. Calling fsync() at the end of test, Enabled.
  13. Using synchronous I/O mode
  14. Doing random r/w test
  15. Threads started!
  16. Done.
  17. Operations performed: 6006 Read, 3996 Write, 1600 Other = 11602 Total
  18. Read 93.844Mb Written 62.438Mb Total transferred 156.28Mb (2.1231Mb/sec)
  19. 135.88 Requests/sec executed
  20. Test execution summary:
  21. total time: 73.6086s
  22. total number of events: 10002
  23. total time taken by event execution: 602.0152
  24. per-request statistics:
  25. min: 0.01ms
  26. avg: 60.19ms
  27. max: 1587.11ms
  28. approx. 95 percentile: 290.98ms
  29. Threads fairness:
  30. events (avg/stddev): 625.1250/42.01
  31. execution time (avg/stddev): 37.6259/2.94
其中主要参数和默认值
  --file-num=N                     创建测试的文件数量 [128]
  --file-block-size=N             块的尺寸,默认是16K 用于测试Oracle一般改为8K[16384]        
  --file-total-size=SIZE         所有测试文件总的大小[2G]
  --file-test-mode=STRING   测试模式 seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)
  --file-io-mode=STRING      文件操作模式 sync(同步),async(异步),fastmmap,slowmmap(两种内存映射模式) [sync]
  --file-rw-ratio=N                测试时的读写比例  [1.5]

  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=STRING     additional flags to use on opening files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]
  --file-fsync-all=[on|off]     do fsync() after each write operation [off]
  --file-fsync-end=[on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]
 
测试完成之后清理生成的文件
[root@mysql1 sysbench]# ./sysbench --test=fileio --file-num=16 --file-total-size=2G cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Removing test files...

如果出现如下错误,则需要注意 指定的file-num能够被file-total-size 整除
FATAL: Too large position discovered in request!

2.进行CPU基准测试
[root@mysql1 sysbench]# ./sysbench --test=cpu --num-threads=16 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 10000
Test execution summary:
    total time:                          2.5106s
    total number of events:              10000
    total time taken by event execution: 39.3201
    per-request statistics:
         min:                                  0.30ms
         avg:                                  3.93ms
         max:                                 43.80ms
         approx.  95 percentile:              15.07ms

Threads fairness:
    events (avg/stddev):           625.0000/50.60
    execution time (avg/stddev):   2.4575/0.03

3.OLTP基准测试
进行准备
[root@mysql1 sysbench]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=xx --mysql-password=xx --mysql-socket=/home/lihuilin/mysql-5.6.14/mysql.sock  --num-threads=15  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@mysql1 sysbench]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=xx --mysql-password=xx --mysql-socket=/home/lihuilin/mysql-5.6.14/mysql.sock  --num-threads=15  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: 15

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  (502.61 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (9549.53 per sec.)
    other operations:                    20000  (1005.21 per sec.)

Test execution summary:
    total time:                          19.8963s
    total number of events:              10000
    total time taken by event execution: 298.1265
    per-request statistics:
         min:                                 11.62ms
         avg:                                 29.81ms
         max:                                185.70ms
         approx.  95 percentile:              42.60ms

Threads fairness:
    events (avg/stddev):           666.6667/5.69
    execution time (avg/stddev):   19.8751/0.01

相对于TPCC-MySQL,sysbench的测试结果非常直观, 一目了然

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29254281/viewspace-1220784/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29254281/viewspace-1220784/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值