Sysbench多線(xiàn)程性能測(cè)試工具
更新時(shí)間:2012年11月29日 08:51:42 作者:
sysbench是一個(gè)多線(xiàn)程性能測(cè)試工具,可以進(jìn)行CPU/內(nèi)存/IO/數(shù)據(jù)庫(kù)等性能測(cè)試,不過(guò)我絕大多數(shù)的時(shí)候都是用它來(lái)對(duì)數(shù)據(jù)庫(kù)(MySQL)進(jìn)行oltp測(cè)試
最近用sysbench進(jìn)行了較多的性能測(cè)試,也總結(jié)一下它的特點(diǎn)和用法和需要注意的事項(xiàng)。sysbench是一個(gè)多線(xiàn)程性能測(cè)試工具,可以進(jìn)行CPU/內(nèi)存/IO/數(shù)據(jù)庫(kù)等性能測(cè)試。不過(guò)我絕大多數(shù)的時(shí)候都是用它來(lái)對(duì)數(shù)據(jù)庫(kù)(MySQL)進(jìn)行oltp測(cè)試。它能測(cè)哪些東西,怎么測(cè)讓我從它的命令幫助來(lái)回答。
~/zbs$ sysbench --help
Missing required command argument.
Usage:
sysbench [general-options]... --test=<test-name> [test-options]... command
上面就大概的用法,--test=指定我們需要測(cè)什么類(lèi)型,那么--test有哪幾種類(lèi)型呢?fileio/cpu/memory/threads/mutex,不好意思前面這幾個(gè)我都沒(méi)測(cè)過(guò),我主要是用它來(lái)測(cè)數(shù)據(jù)庫(kù)的性能,但為什么沒(méi)有數(shù)據(jù)庫(kù)這個(gè)選項(xiàng)呢,這是我是用了最新的版本0.5,它與0.4的版本最大區(qū)別在于支持多表測(cè)試,執(zhí)行實(shí)時(shí)打印統(tǒng)計(jì)信息,支持自定義lua腳本來(lái)設(shè)置測(cè)試行為。
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
如果你用sysbench0.4大概會(huì)看到如下,請(qǐng)注意oltp這個(gè)選項(xiàng)就是測(cè)數(shù)據(jù)庫(kù)用的。
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
看完了測(cè)試模式之后,那么它有一些什么主要的其他控制參數(shù)呢?首先說(shuō)這個(gè)每個(gè)測(cè)試模式自己特有的參數(shù)怎么擦看 sysbench --test=<test-mode> help,比如我這里(請(qǐng)注意,由于sysbench0.5的--test選項(xiàng)對(duì)數(shù)據(jù)庫(kù)的測(cè)試不再使用oltp這個(gè)選項(xiàng)而是通過(guò)指定lua腳本,因此利用前面這個(gè)命令查看不到下面的結(jié)果,所以如果要查看還是通過(guò)0.4的吧,如果誰(shuí)找到了方式在0.5版本里查看oltp的參數(shù)也請(qǐng)告訴一下。另外雖然0.5與0.4版本不同但是參數(shù)還是基本上保持兼容的):
~$ sysbench --test=oltp help
sysbench 0.4.12: multi-threaded system evaluation benchmark
oltp options:
--oltp-test-mode=STRING test type to use {simple,complex,nontrx,sp} [complex]
--oltp-reconnect-mode=STRING reconnect mode {session,transaction,query,random} [session]
--oltp-sp-name=STRING name of store procedure to call in SP test mode []
--oltp-read-only=[on|off] generate only 'read' queries (do not modify database) [off]
--oltp-skip-trx=[on|off] skip BEGIN/COMMIT statements [off]
--oltp-range-size=N range size for range queries [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 mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]
--oltp-auto-inc=[on|off] whether AUTO_INCREMENT (or equivalent) should be used on id column [on]
--oltp-connect-delay=N time in microseconds to sleep after connection to database [10000]
--oltp-user-delay-min=N minimum time in microseconds to sleep after each request [0]
--oltp-user-delay-max=N maximum time in microseconds to sleep after each request [0]
--oltp-table-name=STRING name of test table [sbtest]
--oltp-table-size=N number of records in test table [10000]
--oltp-dist-type=STRING random numbers distribution {uniform,gaussian,special} [special]
--oltp-dist-iter=N number of iterations used for numbers generation [12]
--oltp-dist-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--oltp-dist-res=N percentage of 'special' values to use (for special distribution) [75]
General database options:
--db-driver=STRING specifies database driver to use ('help' to get list of available drivers)
--db-ps-mode=STRING prepared statements usage mode {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 []
上面有這么多參數(shù),相信都能基本看懂吧,我等下舉例的時(shí)候會(huì)講到里面的參數(shù)代表什么含義。然后知道怎么查看具體某個(gè)測(cè)試模式的用法之后再來(lái)看general-options,通用參數(shù),下面看看0.5的參數(shù)(相對(duì)0.4的增加了不少,有些參數(shù)的名稱(chēng)也變了,怎么辨別---對(duì)某個(gè)參數(shù)解釋一模一樣):
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 [64K]
--tx-rate=N target transaction rate (tps) [0]
--report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
--report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
--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 [off]
--rand-init=[on|off] initialize random number generator [off]
--rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
--rand-spec-iter=N number of iterations used for numbers generation [12]
--rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
--rand-seed=N seed for random number generator, ignored when 0 [0]
--rand-pareto-h=N parameter h for pareto distibution [0.2]
~/zbs$ sysbench --help
Missing required command argument.
Usage:
sysbench [general-options]... --test=<test-name> [test-options]... command
上面就大概的用法,--test=指定我們需要測(cè)什么類(lèi)型,那么--test有哪幾種類(lèi)型呢?fileio/cpu/memory/threads/mutex,不好意思前面這幾個(gè)我都沒(méi)測(cè)過(guò),我主要是用它來(lái)測(cè)數(shù)據(jù)庫(kù)的性能,但為什么沒(méi)有數(shù)據(jù)庫(kù)這個(gè)選項(xiàng)呢,這是我是用了最新的版本0.5,它與0.4的版本最大區(qū)別在于支持多表測(cè)試,執(zhí)行實(shí)時(shí)打印統(tǒng)計(jì)信息,支持自定義lua腳本來(lái)設(shè)置測(cè)試行為。
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
如果你用sysbench0.4大概會(huì)看到如下,請(qǐng)注意oltp這個(gè)選項(xiàng)就是測(cè)數(shù)據(jù)庫(kù)用的。
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
看完了測(cè)試模式之后,那么它有一些什么主要的其他控制參數(shù)呢?首先說(shuō)這個(gè)每個(gè)測(cè)試模式自己特有的參數(shù)怎么擦看 sysbench --test=<test-mode> help,比如我這里(請(qǐng)注意,由于sysbench0.5的--test選項(xiàng)對(duì)數(shù)據(jù)庫(kù)的測(cè)試不再使用oltp這個(gè)選項(xiàng)而是通過(guò)指定lua腳本,因此利用前面這個(gè)命令查看不到下面的結(jié)果,所以如果要查看還是通過(guò)0.4的吧,如果誰(shuí)找到了方式在0.5版本里查看oltp的參數(shù)也請(qǐng)告訴一下。另外雖然0.5與0.4版本不同但是參數(shù)還是基本上保持兼容的):
~$ sysbench --test=oltp help
sysbench 0.4.12: multi-threaded system evaluation benchmark
oltp options:
--oltp-test-mode=STRING test type to use {simple,complex,nontrx,sp} [complex]
--oltp-reconnect-mode=STRING reconnect mode {session,transaction,query,random} [session]
--oltp-sp-name=STRING name of store procedure to call in SP test mode []
--oltp-read-only=[on|off] generate only 'read' queries (do not modify database) [off]
--oltp-skip-trx=[on|off] skip BEGIN/COMMIT statements [off]
--oltp-range-size=N range size for range queries [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 mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]
--oltp-auto-inc=[on|off] whether AUTO_INCREMENT (or equivalent) should be used on id column [on]
--oltp-connect-delay=N time in microseconds to sleep after connection to database [10000]
--oltp-user-delay-min=N minimum time in microseconds to sleep after each request [0]
--oltp-user-delay-max=N maximum time in microseconds to sleep after each request [0]
--oltp-table-name=STRING name of test table [sbtest]
--oltp-table-size=N number of records in test table [10000]
--oltp-dist-type=STRING random numbers distribution {uniform,gaussian,special} [special]
--oltp-dist-iter=N number of iterations used for numbers generation [12]
--oltp-dist-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--oltp-dist-res=N percentage of 'special' values to use (for special distribution) [75]
General database options:
--db-driver=STRING specifies database driver to use ('help' to get list of available drivers)
--db-ps-mode=STRING prepared statements usage mode {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 []
上面有這么多參數(shù),相信都能基本看懂吧,我等下舉例的時(shí)候會(huì)講到里面的參數(shù)代表什么含義。然后知道怎么查看具體某個(gè)測(cè)試模式的用法之后再來(lái)看general-options,通用參數(shù),下面看看0.5的參數(shù)(相對(duì)0.4的增加了不少,有些參數(shù)的名稱(chēng)也變了,怎么辨別---對(duì)某個(gè)參數(shù)解釋一模一樣):
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 [64K]
--tx-rate=N target transaction rate (tps) [0]
--report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
--report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
--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 [off]
--rand-init=[on|off] initialize random number generator [off]
--rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
--rand-spec-iter=N number of iterations used for numbers generation [12]
--rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
--rand-seed=N seed for random number generator, ignored when 0 [0]
--rand-pareto-h=N parameter h for pareto distibution [0.2]
您可能感興趣的文章:
- MySQL數(shù)據(jù)庫(kù)基于sysbench實(shí)現(xiàn)OLTP基準(zhǔn)測(cè)試
- 通過(guò)sysbench工具實(shí)現(xiàn)MySQL數(shù)據(jù)庫(kù)的性能測(cè)試的方法
- sysbench對(duì)mysql壓力測(cè)試的詳細(xì)教程
- 使用sysbench來(lái)測(cè)試MySQL性能的詳細(xì)教程
- 用sysbench來(lái)測(cè)試MySQL的性能的教程
- 數(shù)據(jù)庫(kù)工具sysbench安裝教程和性能測(cè)試?yán)?/a>
- sysbench的安裝與使用 分享
- Sysbench對(duì)Mysql進(jìn)行基準(zhǔn)測(cè)試過(guò)程解析
相關(guān)文章
MySQL參數(shù)調(diào)優(yōu)實(shí)例探究講解
本文主要講解MySQL參數(shù)調(diào)優(yōu),包括SQL調(diào)優(yōu)的參數(shù)解析,如何在生產(chǎn)環(huán)境調(diào)優(yōu),文中根據(jù)不同的數(shù)據(jù)庫(kù)參數(shù)給出調(diào)優(yōu)建議與應(yīng)用場(chǎng)景2022-11-11
MySQL 主從復(fù)制數(shù)據(jù)不一致的解決方法
本文主要介紹了MySQL 主從復(fù)制數(shù)據(jù)不一致的解決方法,文中根據(jù)實(shí)例編碼詳細(xì)介紹的十分詳盡,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
mysql數(shù)據(jù)遷移之data目錄復(fù)制方法
這篇文章主要給大家介紹了關(guān)于mysql數(shù)據(jù)遷移之data目錄復(fù)制方法的相關(guān)資料,MySQL的data文件是存儲(chǔ)數(shù)據(jù)庫(kù)的核心文件,它包含了所有的表、索引、視圖和其它相關(guān)的數(shù)據(jù),通過(guò)復(fù)制這些文件,我們可以將一個(gè)MySQL數(shù)據(jù)庫(kù)遷移到另一個(gè)地方,需要的朋友可以參考下2023-08-08
使用mysql語(yǔ)句對(duì)分組結(jié)果進(jìn)行再次篩選方式
這篇文章主要介紹了使用mysql語(yǔ)句對(duì)分組結(jié)果進(jìn)行再次篩選方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-08-08
MySQL 數(shù)據(jù)庫(kù)對(duì)服務(wù)器端光標(biāo)的限制
從MySQL 5.0.2開(kāi)始,通過(guò)mysql_stmt_attr_set() C API函數(shù)實(shí)現(xiàn)了服務(wù)器端光標(biāo)。服務(wù)器端光標(biāo)允許在服務(wù)器端生成結(jié)果集,但不會(huì)將其傳輸?shù)娇蛻?hù)端,除非客戶(hù)端請(qǐng)求這些行。2009-03-03
MySQL 索引和數(shù)據(jù)表該如何維護(hù)
使用合適的數(shù)據(jù)類(lèi)型完成數(shù)據(jù)表創(chuàng)建和建立索引后,工作并沒(méi)有完結(jié)——你需要去維護(hù)數(shù)據(jù)表和索引以保證它們運(yùn)行良好。數(shù)據(jù)表維護(hù)的主要目的是查找和修復(fù)沖突,維護(hù)精確的索引統(tǒng)計(jì)和減少碎片。2021-05-05
MySQL數(shù)據(jù)庫(kù)21條最佳性能優(yōu)化經(jīng)驗(yàn)
數(shù)據(jù)庫(kù)的操作越來(lái)越成為整個(gè)應(yīng)用的性能瓶頸了,這點(diǎn)對(duì)于Web應(yīng)用尤其明顯。這篇文章主要介紹了MySQL數(shù)據(jù)庫(kù)21條最佳性能優(yōu)化經(jīng)驗(yàn)的相關(guān)資料,需要的朋友可以參考下2016-10-10

