首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 數據庫知識 >  >> MySQL 資料庫 >> MySQL 綜合教學

Sysbench 0.4.12 編譯安裝避坑指南:libtool 錯誤修復與 CPU 基準測試

     編輯:MySQL 綜合教學

Sysbench 0.4.12 編譯安裝避坑指南:libtool 錯誤修復與 CPU 基準測試

Sysbench 0.4 系列在老系統 (RHEL 6、CentOS 6) 上仍有廣泛使用。本文記錄編譯安裝中常見的 libtool 鏈接錯誤修復方案,並演示 CPU 基準測試全過程。

環境基線

  • OS: RHEL 6.2 x86_64
  • MySQL: 5.6.16 源碼安裝於 /usr/local/mysql
  • Sysbench: 0.4.12 (SourceForge 最後版本)

編譯安裝步驟

tar -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 命令未找到

../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

  1. 確認系統 libtool 可用:which libtool → /usr/bin/libtool
  2. 編輯 aclocal.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
  1. 重新生成構建腳本並編譯:
autoreconf -fiv  # 或 ./autogen.sh (若存在)
./configure --with-mysql-includes=... --with-mysql-libs=...
make && make install

運行時依賴修復:libmysqlclient.so.18 找不到

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

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

結果解讀

  • total time:單線程完成 10000 次素數檢測耗時 40.45s。
  • avg 4.04ms:單次事件平均耗時,反映 CPU 單核整數運算能力。
  • 95% 分位 5.20ms:95% 請求在 5.2ms 內完成,尾部延遲可觀。
  • Threads fairness:單線程無公平性問題。

多線程擴展測試

sysbench --test=cpu --cpu-max-prime=20000 --threads=8 run
# 觀察 total time 是否接近單線程 1/8,評估 CPU 縮放效率

版本升級建議

Sysbench 0.4 系列已停止維護,**強烈建議遷移至 1.0+ (GitHub akopytov/sysbench)**:

  • 支持 Lua 腳本自定義負載。
  • 原生支持 MySQL 8.0、PostgreSQL 10+、Redis 等。
  • 修復大量舊版 Bug,命令行介面重設計,輸出格式標準化 (JSON/CSV)。
  • 安裝更簡單:yum install sysbench (EPEL) 或 apt install sysbench。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved