mysql benchmark基准测试
git項(xiàng)目地址:
https://github.com/akopytov/sysbench
利用sysbench很容易對(duì)mysql做性能基準(zhǔn)測(cè)試(當(dāng)然這個(gè)工具很強(qiáng)大,除了測(cè)試主流數(shù)據(jù)庫(kù)性能,還能測(cè)試其它方面,詳情自己看官網(wǎng)項(xiàng)目文檔)
?
mac上的用法:
一、安裝?
brew install sysbench
?
二、先在mysql上創(chuàng)建一個(gè)專門(mén)的測(cè)試數(shù)據(jù)庫(kù),比如test
?
三、利用sysbench先生成測(cè)試數(shù)據(jù)?
sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test \ --mysql-table-engine=innodb \ --mysql-host=localhost \ --mysql-db=test \ --mysql-user=root \ --mysql-password=*** \ prepare上面這一堆的意思,是在本機(jī)localhost的test數(shù)據(jù)庫(kù)的t_test中創(chuàng)建500萬(wàn)條測(cè)試數(shù)據(jù),表的數(shù)據(jù)庫(kù)引擎為innodb.
tips:如果想知道還有哪些參數(shù)可用,可輸入命令
sysbench --test=oltp helpcentos上如果用yum install sysbench安裝的話,運(yùn)行時(shí)可能會(huì)出現(xiàn)
FATAL: no database driver specified
FATAL: failed to initialize database driver!
可以加上參數(shù)?--db-driver=mysql ,原因是yum方式安裝時(shí),同時(shí)安裝了mysql與其它數(shù)據(jù)庫(kù)的驅(qū)動(dòng),不指定驅(qū)動(dòng)類型的話,sysbench不知道你是要測(cè)試是mysql,還是oracle之類的其它數(shù)據(jù)庫(kù)
?
四、運(yùn)行測(cè)試
sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test \ --mysql-table-engine=innodb \ --mysql-host=localhost \ --mysql-db=test \ --mysql-user=root \ --mysql-password=*** \ run最后一個(gè)prepare改成run就行了,測(cè)試完后,會(huì)輸出類似以下結(jié)果:
sysbench 0.4.12: multi-threaded system evaluation benchmarkNo DB drivers specified, using mysql Running the test with following options: Number of threads: 1Doing 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: 140000write: 50000other: 20000total: 210000transactions: 10000 (514.48 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190000 (9775.14 per sec.)other operations: 20000 (1028.96 per sec.)Test execution summary:total time: 19.4371stotal number of events: 10000total time taken by event execution: 19.3581per-request statistics:min: 1.65msavg: 1.94msmax: 13.48msapprox. 95 percentile: 2.34msThreads fairness:events (avg/stddev): 10000.0000/0.00execution time (avg/stddev): 19.3581/0.00一般我們比較關(guān)心:
transactions: 10000 (514.48 per sec.)read/write requests: 190000 (9775.14 per sec.)這代表每秒能處理的事務(wù)數(shù),以及每秒的讀寫(xiě)次數(shù)。
?
五、清理測(cè)試數(shù)據(jù)
sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test \ --mysql-table-engine=innodb \ --mysql-host=localhost \ --mysql-db=test \ --mysql-user=root \ --mysql-password=*** \ cleanup最后一個(gè)換成cleanup即可。
?
春晚實(shí)在太無(wú)聊了,還不如寫(xiě)二行代碼有意思,祝各位園友猴年大吉,身體健康,心想事成!
轉(zhuǎn)載于:https://www.cnblogs.com/yjmyzz/p/mysql-benchmark-use-sysbench.html
總結(jié)
以上是生活随笔為你收集整理的mysql benchmark基准测试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: POJ2115 C Looooops(线
- 下一篇: MySQL中CREATE DATABAS