環境:RHEL 6.2 (Santiago)、MySQL 5.6.16 編譯安裝於 /usr/local/mysql。嘗試執行自帶基準測試腳本 test-insert 時拋出錯誤:
Can't locate DBI.pm in @INC ... BEGIN failed--compilation aborted at ./test-insert line 33.
顯然缺少 Perl DBI(Database Interface)模組,這是 Perl 連接資料庫的核心介面。
rpm -qa | grep perl-DB
無輸出,確認未安裝相關 RPM 包。
從 RHEL 6.2 安裝光碟 Packages 目錄下依序安裝三個包:
# 1. 核心 DBI 介面 rpm -ivh perl-DBI-1.609-4.el6.i686.rpm # 2. 相容庫(關鍵:提供 libmysqlclient.so.16) rpm -ivh MySQL-shared-compat-5.6.16-1.el6.i686.rpm # 3. MySQL 驅動 rpm -ivh perl-DBD-MySQL-4.013-3.el6.i686.rpm
直接安裝 perl-DBD-MySQL 時會報錯:
error: Failed dependencies:
libmysqlclient.so.16 is needed by perl-DBD-MySQL-4.013-3.el6.i686
libmysqlclient.so.16(libmysqlclient_16) is needed by ...
檢查編譯安裝的 MySQL 目錄:
ls -l /usr/local/mysql/lib/libmysqlclient.so.* # 僅存在 so.18 版本,無 so.16
根因: 編譯安裝預設不包含舊版相容庫,而 RPM 套件 MySQL-shared-compat 專門提供 libmysqlclient.so.16 等歷史版本庫,解決第三方組件相依問題。
安裝完成後執行插入效能測試:
./test-insert --server=mysql --user=root --password=mysql --log
輸出片段:
Testing server 'MySQL 5.6.16' at 2014-02-15 16:36:17 Testing the speed of inserting data into 1 table and do some selects on it. The tests are done with a table that has 100000 rows. ... Time for insert (300000): 879 wallclock secs ( 3.51 usr 1.21 sys + 0.00 cusr 0.00 csys = 4.72 CPU) Time for insert_duplicates (100000): 18 wallclock secs ( 3.81 usr 1.41 sys + 0.00 cusr 0.00 csys = 5.22 CPU) Test of prepared+execute/once prepared many execute selects Time for prepared_select (100000): 31 wallclock secs (10.87 usr 1.81 sys + 0.00 cusr 0.00 csys = 12.68 CPU)
測試成功跑通,獲得基準效能數據(文中註記機器較差,數據僅供流程參考)。
MySQL-shared-compat RPM 包