Sysbench 0.4 系列在老系統 (RHEL 6、CentOS 6) 上仍有廣泛使用。本文記錄編譯安裝中常見的 libtool 鏈接錯誤修復方案,並演示 CPU 基準測試全過程。
/usr/local/mysqltar -xvf sysbench-0.4.12.tar.gz cd sysbench-0.4.12 ./configure \ --with-mysql-includes=/usr/local/mysql/include \ --with-mysql-libs=/usr/local/mysql/lib \ && make && make install
../libtool: line 841: X--tag=CC: command not found ../libtool: line 874: libtool: ignoring unknown tag : command not found ../libtool: line 1954: X-L/usr/local/mysql/lib: No such file or directory ...
原因:源碼自帶 libtool 腳本與系統環境不兼容 (常見於 automake 版本不匹配)。
libtool 可用:which libtool → /usr/bin/libtoolaclocal.m4,定位 LIBTOOL 定義:# Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl
修改為:
LIBTOOL='$(SHELL) /usr/bin/libtool' AC_SUBST(LIBTOOL)dnl
autoreconf -fiv # 或 ./autogen.sh (若存在) ./configure --with-mysql-includes=... --with-mysql-libs=... make && make install
sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file
建立軟鏈接到系統庫目錄:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/ # 或配置 ld.so.conf echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf ldconfig
[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
sysbench --test=cpu --cpu-max-prime=20000 --threads=8 run # 觀察 total time 是否接近單線程 1/8,評估 CPU 縮放效率
Sysbench 0.4 系列已停止維護,**強烈建議遷移至 1.0+ (GitHub akopytov/sysbench)**:
yum install sysbench (EPEL) 或 apt install sysbench。