一、安裝
我的安裝過程去官網上面下載下源碼,然後安裝。
系統:CentOS release 5.3
安裝過程首先運行autogen.sh
然後通過locate mysql找到mysql的include和lib的位置
./configure --prefix=/usr/sysbench --with-mysql-includes=/usr/include/mysql/ --with-mysql-libs=/usr/lib64/mysql/
make
make install
二、使用
在使用之前必須創建好數據庫,可以創建成默認的sbtest,然後就不用指定該參數了,下面是官方文檔中關於這個參數的說明:
--mysql-db
|
MySQL database name. Note SysBench will not automatically create this database. You should create it manually and grant the appropriate privileges to a user which will be used to access the test table. | sbtest |
假如沒有創建的話,sysbench會報錯,提示:
FATAL: unable to connect to MySQL server, aborting...
FATAL: error 1049: Unknown database 'sbtest'
FATAL: failed to connect to database server!
害我檢查了半天,以爲是用戶名和密碼的問題
具體使用以及參數可以參照下面的文章:
http://www.ningoo.net/html/2009/performance_test_tool_sysbench.html
下面是我的prepare過程
/usr/sysbench/bin/sysbench --debug=off --test=oltp --mysql-table-engine=innodb --oltp-table-size=2000000 --mysql-socket=/data/mysql/ha_master/mysql.sock --num-threads=8 --max-requests=0 --mysql-user=root --mysql-password=*** --mysql-host=localhost prepare