共計 4877 個字符,預計需要花費 13 分鐘才能閱讀完成。
這篇文章給大家分享的是有關 Sysbench 基準測試的示例分析的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
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 測試
準備文件
進行基準測試
[root@mysql1 sysbench]# ./sysbench –test=fileio –file-total-size=2G –file-test-mode=rndrw –file-num=16 –num-threads=16 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Extra file open flags: 0
16 files, 128Mb each
2Gb 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: 6006 Read, 3996 Write, 1600 Other = 11602 Total
Read 93.844Mb Written 62.438Mb Total transferred 156.28Mb (2.1231Mb/sec)
135.88 Requests/sec executed
Test execution summary:
total time: 73.6086s
total number of events: 10002
total time taken by event execution: 602.0152
per-request statistics:
min: 0.01ms
avg: 60.19ms
max: 1587.11ms
approx. 95 percentile: 290.98ms
Threads fairness:
events (avg/stddev): 625.1250/42.01
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 的測試結果非常直觀, 一目了然
感謝各位的閱讀!關于“Sysbench 基準測試的示例分析”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!