摘要:
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

root@db2:~# sysbench --test=fileio help
sysbench 0.4.12: multi-threaded system evaluation benchmark
fileio options:
--file-num=N 創建測試文件的數量。默認是128
--file-block-size=N 測試時文件塊的大小。默認是16384(16K)
--file-total-size=SIZE 測試文件的總大小。默認是2G
--file-test-mode=STRING 文件測試模式{seqwr(順序寫), seqrewr(順序讀寫), seqrd(順序讀), rndrd(隨機讀), rndwr(隨機寫), rndrw(隨機讀寫)}
--file-io-mode=STRING 文件操作模式{sync(同步),async(異步),fastmmap(快速map映射),slowmmap(慢map映射)}。默認是sync
--file-extra-flags=STRING 使用額外的標志來打開文件{sync,dsync,direct} 。默認為空
--file-fsync-freq=N 執行fsync()的頻率。(0 – 不使用fsync())。默認是100
--file-fsync-all=[on|off] 每執行完一次寫操作就執行一次fsync。默認是off
--file-fsync-end=[on|off] 在測試結束時才執行fsync。默認是on
--file-fsync-mode=STRING 使用哪種方法進行同步{fsync, fdatasync}。默認是fsync
--file-merged-requests=N 如果可以,合並最多的IO請求數(0 – 表示不合並)。默認是0
--file-rw-ratio=N 測試時的讀寫比例。默認是1.5
2):sysbench --test=cpu help

--cpu-max-prime=N 最大質數發生器數量。默認是10000
3):sysbench --test=memory help

root@db2:~# sysbench --test=memory help
sysbench 0.4.12: multi-threaded system evaluation benchmark
memory options:
--memory-block-size=SIZE 測試時內存塊大小。默認是1K
--memory-total-size=SIZE 傳輸數據的總大小。默認是100G
--memory-scope=STRING 內存訪問范圍{global,local}。默認是global
--memory-hugetlb=[on|off] 從HugeTLB池內存分配。默認是off
--memory-oper=STRING 內存操作類型。{read, write, none} 默認是write
--memory-access-mode=STRING存儲器存取方式{seq,rnd} 默認是seq
4):sysbench --test=threads help

sysbench 0.4.12: multi-threaded system evaluation benchmark
threads options:
--thread-yields=N 每個請求產生多少個線程。默認是1000
--thread-locks=N 每個線程的鎖的數量。默認是8
5):sysbench --test=mutex help

root@db2:~# sysbench --test=mutex help
sysbench 0.4.12: multi-threaded system evaluation benchmark
mutex options:
--mutex-num=N 數組互斥的總大小。默認是4096
--mutex-locks=N 每個線程互斥鎖的數量。默認是50000
--mutex-loops=N 內部互斥鎖的空循環數量。默認是10000
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

root@db2:~# sysbench --test=cpu --cpu-max-prime=2000 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 2000
Test execution summary:
total time: 3.7155s
total number of events: 10000
total time taken by event execution: 3.7041
per-request statistics:
min: 0.36ms
avg: 0.37ms
max: 2.53ms
approx. 95 percentile: 0.37ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 3.7041/0.00
2)測試線程:sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run

root@db2:~# sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 500
Doing thread subsystem performance test
Thread yields per test: 100 Locks used: 4
Threads started!
Done.
Test execution summary:
total time: 1.0644s
total number of events: 10000
total time taken by event execution: 501.3952
per-request statistics:
min: 0.05ms
avg: 50.14ms
max: 587.05ms
approx. 95 percentile: 190.28ms
Threads fairness:
events (avg/stddev): 20.0000/4.72
execution time (avg/stddev): 1.0028/0.01
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

root@db2:~/io# sysbench --test=fileio --num-threads=16 --file-total-size=2G --file-test-mode=rndrw prepare
sysbench 0.4.12: multi-threaded system evaluation benchmark
128 files, 16384Kb each, 2048Mb total
Creating files for the test...
root@db2:~/io# sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 20
Extra file open flags: 0
128 files, 16Mb 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: 6010 Read, 3997 Write, 12803 Other = 22810 Total
Read 93.906Mb Written 62.453Mb Total transferred 156.36Mb (6.6668Mb/sec)
426.68 Requests/sec executed
Test execution summary:
total time: 23.4534s
total number of events: 10007
total time taken by event execution: 111.5569
per-request statistics:
min: 0.01ms
avg: 11.15ms
max: 496.18ms
approx. 95 percentile: 53.05ms
Threads fairness:
events (avg/stddev): 500.3500/37.50
execution time (avg/stddev): 5.5778/0.21
root@db2:~/io# sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw cleanup
sysbench 0.4.12: multi-threaded system evaluation benchmark
Removing test files...
4)測試內存:sysbench --test=memory --memory-block-size=8k --memory-total-size=1G 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
5)測試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
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=1234#
###################################更新2016-07-27
今天使用sysbench的時候,發現0.5版本已經沒有 --test=oltp的參數,現在就更新說明下0.5版本的sysbench 如何使用oltp的測試。
① 安裝:通過apt-get install sysbench
root@t22:~# sysbench --test=oltp help sysbench 0.5: multi-threaded system evaluation benchmark PANIC: unprotected error in call to Lua API (cannot open oltp: No such file or directory)
sysbench 0.5相比0.4版本有一些變化,包括oltp測試結合了lua腳本。通過dpkg -L sysbench查看相關文件:
root@t22:~# dpkg -L sysbench /. /usr /usr/bin /usr/bin/sysbench /usr/share /usr/share/doc /usr/share/doc/sysbench /usr/share/doc/sysbench/copyright /usr/share/doc/sysbench/TODO /usr/share/doc/sysbench/changelog.Debian.gz /usr/share/doc/sysbench/README /usr/share/doc/sysbench/manual.html /usr/share/doc/sysbench/tests /usr/share/doc/sysbench/tests/db /usr/share/doc/sysbench/tests/db/oltp_simple.lua /usr/share/doc/sysbench/tests/db/insert.lua /usr/share/doc/sysbench/tests/db/select_random_ranges.lua /usr/share/doc/sysbench/tests/db/oltp.lua /usr/share/doc/sysbench/tests/db/common.lua /usr/share/doc/sysbench/tests/db/select_random_points.lua /usr/share/doc/sysbench/tests/db/delete.lua /usr/share/doc/sysbench/tests/db/update_non_index.lua /usr/share/doc/sysbench/tests/db/update_index.lua /usr/share/doc/sysbench/tests/db/parallel_prepare.lua /usr/share/doc/sysbench/tests/db/select.lua
②:參數介紹
--test=tests/db/oltp.lua 表示調用 tests/db/oltp.lua 腳本進行 oltp 模式測試
--mysql-table-engine=innodb 表示選擇測試表的存儲引擎 --oltp_tables_count=10 表示會生成 10 個測試表 --oltp-table-size=100000 表示每個測試表填充數據量為 100000 --rand-init=on 表示每個測試表都是用隨機數據來填充的 如果在本機,也可以使用 –mysql-socket 指定 socket 文件來連接。加載測試數據時長視數據量而定,若過程比較久需要稍加耐心等待。
--num-threads=8 表示發起 8個並發連接 --oltp-read-only=off 表示不要進行只讀測試,也就是會采用讀寫混合模式測試 --report-interval=10 表示每10秒輸出一次測試進度報告 --rand-type=uniform 表示隨機類型為固定模式,其他幾個可選隨機模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托) --max-time=120 表示最大執行時長為 120秒 --max-requests=0 表示總請求數為 0,因為上面已經定義了總執行時長,所以總請求數可以設定為 0;也可以只設定總請求數,不設定最大執行時長 --percentile=99 表示設定采樣比例,默認是 95%,即丟棄1%的長請求,在剩余的99%里取最大值
具體的說明可以看sysbench安裝、使用、結果解讀和使用sysbench對mysql壓力測試。
③:使用說明
初始化數據:prepare。在本地數據庫的dba_test庫中,初始化三張表(sbtest1、sbtest2、sbtest3),存儲引擎是innodb,每張表50萬數據。
sysbench --test=/usr/share/doc/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --mysql-host=127.0.0.1 --mysql-db=dba_test --oltp-table-size=500000 --oltp_tables_count=3 --rand-init=on --mysql-user=zjy --mysql-password=zjy prepare
因為是本機測試,所以也可以用也可以使用--mysql-socket指定socket文件來連接。
測試:run。模擬對3個表並發OLTP測試,每個表50萬行記錄,持續壓測時間為5分鍾。
sysbench --test=/usr/share/doc/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --mysql-host=127.0.0.1 --mysql-db=dba_test --num-threads=8 --oltp-table-size=500000 --oltp_tables_count=3 --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=600 --max-requests=0 --percentile=99 --mysql-user=zjy --mysql-password=zjy run
上面跑完會出一個結果:
#每10秒鍾報告一次測試結果,tps、每秒讀、每秒寫、95%以上的響應時長統計 [ 10s] threads: 8, tps: 66.60, reads: 943.67, writes: 269.62, response time: 431.72ms (95%), errors: 0.00, reconnects: 0.00 [ 20s] threads: 8, tps: 34.30, reads: 480.20, writes: 137.20, response time: 598.28ms (95%), errors: 0.00, reconnects: 0.00 [ 30s] threads: 8, tps: 36.60, reads: 512.40, writes: 146.40, response time: 494.87ms (95%), errors: 0.00, reconnects: 0.00 OLTP test statistics: queries performed: read: 941248 #讀總數 write: 268928 #寫總數 other: 134464 #其他操作總數(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等) total: 1344640 #全部總數 transactions: 67232 (112.04 per sec.) #總事務數(每秒事務數) read/write requests: 1210176 (2016.73 per sec.) #讀寫總數(每秒讀寫次數) other operations: 134464 (224.08 per sec.) #其他操作總數(每秒其他操作次數) ignored errors: 0 (0.00 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 600.0698s #總耗時 total number of events: 67232 #共發生多少事務數 total time taken by event execution: 4799.8569s # 所有事務耗時相加(不考慮並行因素) response time: min: 2.09ms #最小耗時 avg: 71.39ms #平均耗時 max: 839.32ms #最大耗時 approx. 95 percentile: 309.40ms 超過95%平均耗時 Threads fairness: events (avg/stddev): 8404.0000/17.56 execution time (avg/stddev): 599.9821/0.02
清理數據:cleanup
sysbench --test=/usr/share/doc/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --mysql-host=127.0.0.1 --mysql-db=dba_test --num-threads=8 --oltp-table-size=500000 --oltp_tables_count=3 --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=600 --max-requests=0 --mysql-user=zjy --mysql-password=zjy cleanup
更多0.5版本的sysbench可以看sysbench安裝、使用、結果解讀和使用sysbench對mysql壓力測試。