一、獲取安裝包
最近的版本為0.4.12,下載地址:http://sourceforge.net/projects/sysbench/
二、編譯安裝
我的環境為RHEL6.2 + MySQL 5.6.16,搭建參考上兩篇文章<<RHEL6.2編譯安裝MySQL 5.6.16>><<MySQL Benchmark安裝DBI組件>>,安裝步驟如下:
復制代碼 代碼如下:
[root@beanvm ~]# tar -xvf sysbench-0.4.12.tar.gz
[root@beanvm ~]# cd sysbench-0.4.12
[root@beanvm sysbench-0.4.12]# ./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib && make && make install
因為我的MySQL是編譯安裝的,所以上面需要給出MySQL的庫文件位置(對應—with—mysql-includes和–with-mysql-libs選項)。
安裝過程中常見的報錯如下:
復制代碼 代碼如下:
../libtool: line 841: X--tag=CC: command not found
../libtool: line 874: libtool: ignoring unknown tag : command not found
../libtool: line 841: X--mode=link: command not found
../libtool: line 1007: *** Warning: inferring the mode of operation is deprecated.: command not found
../libtool: line 1008: *** Future versions of Libtool will require --mode=MODE be specified.: command not found
../libtool: line 2234: X-g: command not found
../libtool: line 2234: X-O2: command not found
../libtool: line 1954: X-L/usr/local/mysql/lib: No such file or directory
../libtool: line 2403: Xsysbench: command not found
在之前版本中,碰見這個問題我們只需要在編譯操作前執行sysbench解壓目錄下的autogen.sh腳本即可;不過現在這樣做還是會報同樣的錯誤,原因是sysbench自帶的libtool有問題,我們可以比較它和/usr/bin/libtool文件的區別得知,總之可以通過替換這個libtool文件來解決,或者修改aclocal.m4文件的如下內容
復制代碼 代碼如下:
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
AC_SUBST(LIBTOOL)dnl
將LIBTOOL變量的值修改為:'$(SHELL) /usr/bin/libtool',即使用系統的libtool工具包。
修改後再執行make && make install即可順利安裝。
安裝完成馬上測試一下:
復制代碼 代碼如下:
[root@beanvm sysbench-0.4.12]# sysbench
sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
說是缺少libmysqlclient.so.18文件,額,這個文件是存在的,需要手動鏈接一下:
復制代碼 代碼如下:
[root@beanvm ~]# ls -l /usr/local/mysql/lib/libmysqlclient.so.18*
lrwxrwxrwx. 1 mysql mysql 24 Feb 15 14:39 /usr/local/mysql/lib/libmysqlclient.so.18 -> libmysqlclient.so.18.1.0
-rwxr-xr-x. 1 mysql mysql 7654927 Feb 15 14:30 /usr/local/mysql/lib/libmysqlclient.so.18.1.0
[root@beanvm ~]# ls -l /usr/lib/libmysqlclient.so.18*
ls: cannot access /usr/lib/libmysqlclient.so.18*: No such file or directory
[root@beanvm ~]# ln ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/
部署完成,運行一個CPU基准測試:
復制代碼 代碼如下:
[root@beanvm ~]# sysbench --test=cpu --cpu-max-prime=20000 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: 20000
Test execution summary:
total time: 40.4541s
total number of events: 10000
total time taken by event execution: 40.4165
per-request statistics:
min: 3.64ms
avg: 4.04ms
max: 21.82ms
approx. 95 percentile: 5.20ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 40.4165/0.00
x86的指令集基本是向上兼容的,在新cpu上運行老代碼是可以的。
如果是全新的指令集,cpu廠家在設計時就會有指令集和匯編程序了,現在一般廠商至少提供c語言編譯程序。
如果自己開發編譯程序,前端(詞法分析到中間代碼生成)一般不用動,後端是要自己寫的。
去掉 -march=arm6試下吧。