[xml] view plaincopy
當(dāng)然了,用上面的參數(shù)編譯的話,就要確保你的 MySQL lib目錄下有對應(yīng)的 so 文件,如果沒有,可以自己下載 devel 或者 share 包來安裝。
注意,因?yàn)楸痉?wù)器是靜態(tài)編譯安裝,無法正常安裝,下載了一個noinstall版本的安裝的
另外,如果想要讓 sysbench 支持 pgsql/oracle 的話,就需要在編譯的時候加上參數(shù)
–with-pgsql
或者
–with-oracle
這2個參數(shù)默認(rèn)是關(guān)閉的,只有 MySQL 是默認(rèn)支持的。
二、開始測試
編譯成功之后,就要開始測試各種性能了,測試的方法官網(wǎng)網(wǎng)站上也提到一些,但涉及到 OLTP 測試的部分卻不夠準(zhǔn)確。在這里我大致提一下:
1、cpu性能測試
sysbench –test=cpu –cpu-max-prime=20000 run
cpu測試主要是進(jìn)行素?cái)?shù)的加法運(yùn)算,在上面的例子中,指定了最大的素?cái)?shù)為 20000,自己可以根據(jù)機(jī)器cpu的性能來適當(dāng)調(diào)整數(shù)值。
2、線程測試
sysbench –test=threads –num-threads=64 –thread-yields=100 –thread-locks=2 run
3、磁盤IO性能測試
sysbench –test=fileio –num-threads=16 –file-total-size=3G –file-test-mode=rndrw prepare
sysbench –test=fileio –num-threads=16 –file-total-size=3G –file-test-mode=rndrw run
sysbench –test=fileio –num-threads=16 –file-total-size=3G –file-test-mode=rndrw cleanup
上述參數(shù)指定了最大創(chuàng)建16個線程,創(chuàng)建的文件總大小為3G,文件讀寫模式為隨機(jī)讀。
4、內(nèi)存測試
sysbench –test=memory –memory-block-size=8k –memory-total-size=4G run
上述參數(shù)指定了本次測試整個過程是在內(nèi)存中傳輸 4G 的數(shù)據(jù)量,每個 block 大小為 8K。
5、OLTP測試
sysbench –test=oltp –mysql-table-engine=myisam –oltp-table-size=1000000 –mysql-socket=/tmp/mysql.sock –mysql-user=test –mysql-host=localhost –mysql-password=test prepare
上述參數(shù)指定了本次測試的表存儲引擎類型為 myisam,這里需要注意的是,官方網(wǎng)站上的參數(shù)有一處有誤,即 –mysql-table-engine,官方網(wǎng)站上寫的是 –mysql-table-type,這個應(yīng)該是沒有及時更新導(dǎo)致的。另外,指定了表最大記錄數(shù)為 1000000,其他參數(shù)就很好理解了,主要是指定登錄方式。測試 OLTP 時,可以自己先創(chuàng)建數(shù)據(jù)庫 sbtest,或者自己用參數(shù) –mysql-db 來指定其他數(shù)據(jù)庫。–mysql-table-engine 還可以指定為 innodb 等 MySQL 支持的表存儲引擎類型。 .
Sysbench 代碼sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \--mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=4 run Sysbench-install 代碼sysbench – Linux test bench. Easy as pie to test CPU, memory, threads, mysql, and disk performance. Full description is available here: http://sysbench.sourceforge.net/docs/ install mysql, mysql-develwget http://superb-west.dl.sourceforge.net/sourceforge/sysbench/sysbench-0.4.8.tar.gztar xvzf sysbench*gzcd sysbench*./configure && make installmysql tests This will run 10 separate consecutive mysql tests using an InnoDB table type, each with 100 mysql threads, doing a total of 1000 various SQL operations per test. Then it will print the total time they took to finish: sysbench --test=oltp --mysql-user=USER --mysql-password=PASS --mysql-db=test --mysql-host='HOST' --mysql-table-engine=innodb prepare time perl -e "foreach(1..10){print \`sysbench --max-requests=1000 --test=oltp --mysql-user=USER --mysql-password=PASS --mysql-db=test --mysql-host='HOST' --mysql-table-engine=innodb --num-threads=100 run\`}" sysbench --test=oltp --mysql-user=USER --mysql-password=PASS --mysql-db=test --mysql-host='HOST' cleanup