2011年4月7日星期四

MySQL 5.1 使用 PLUGIN

采用如下参数编译 MySQL 5.1 版本
[bash]
[root@localhost mysql-5.1.56]# ./configure --prefix=/usr/local/mysql/ \
--without-debug \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--enable-assembler \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-extra-charsets=latin1,gb2312 \
--with-pthread --enable-thread-safe-client \
--with-plugins=myisam,innodb_plugin,innobase
[/bash]
在 client 使用命令
[sql]
mysql> INSERT PLUGIN plugin_name SONAME 'plugin_name.so';
[/sql]
提示如下错误

ERROR 1289 (HY000): The 'plugin' feature is disabled; you need MySQL built with 'HAVE_DLOPEN' to have it working


Bug #45605 是类似问题, 中间回复有一段说明产生如上错误是因为编译时有使用参数 --with-mysqld-ldflags=-all-static

- Why does the compilation process not recognize that Ubuntu default install supports HAVE_DLOPEN ?
Server was built with --with-mysqld-ldflags=-all-static


查资料时, 有说到在编译之前, 先设置如下两个环境变量就可以解决问题
[bash]
# export CFLAGS="-O2 -DHAVE_DLOPEN=1"
# export CXXFLAGS="-O2 -DHAVE_DLOPEN=1"
[/bash]
但我测试后, 编译倒完全不能通过. 不知道有木有人采用这种方法有解决了问题的?

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.

MySQL 5.1.56 使用 InnoDB

之前編譯 MySQL 5.1.54, 使用如下參數
[bash]
[root@localhost mysql-5.1.54]# ./configure --prefix=/usr/local/mysql/ \
--without-debug \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--enable-assembler \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-extra-charsets=latin1,gb2312 \
--with-pthread --enable-thread-safe-client \
--with-plugins=myisam,innodb_plugin
[/bash]
編譯後, stoRe engine 可使用 InnoDB. 但這次因為測試 HandlerSocket, 到官方下載的是 MySQL 5.1.56 的源代碼, 同樣使用如上同樣的參數, 但不能使用 InnoDB, 後面做多番嘗試沒成功後, 將後面參數修改為 --with-plugins=myisam,innodb_plugin,innobase後, 再編譯安裝, OK.

/bin/rm: cannot remove 'libtoolT': No such file or directory

安裝 MySQL 5.1.56,編譯時報如下錯誤

/bin/rm: cannot remove `libtoolT’: No such file or directory

忽略錯誤,強制make,出錯.網上查了下,有很多提到採用
[bash]
# aclocal
# autoconf
# automake
# libtoolize –force
[/bash]
OR
[bash]
# autoreconf –force –install
# libtoolize –automake –force
# automake –force –add-missing
[/bash]
但安裝無法成功.

Debian Bug report logs - #523750 autoconf false error這裡是類似的錯誤,臨時解決方法是刪除 /usr/share/aclocal/libtool.m4 文件中的 680 行$RM -f "$cfgfile", 遂按此方法重新編譯安裝,還是失敗.

Package: libtool
Version: 2.2.6a-2
Normal run of libtool, produces no other warnings until the end of the master configure script.
At which point out pops:
config.status: executing libtool commands
/bin/rm: cannot remove `libtoolT': No such file or directory
This is resolved by placing:
$RM -f "$cfgfile"
at line 680 of /usr/share/aclocal/libtool.m4
One thing to note, is that the package producing this error has been bootstrapped to install libLtdl and related stuff under lib/libLtdl instead of the defaults.
The actual error may be elsewhere with a failure of the macro to detect and handle that case.


因為在上段引用中,有看到提到 libLtdl,於是,搜索了下,在 11.6 How to distribute libltdl with your package,看到聲明 libLtdl 的路徑libtoolize --ltdl, 用這種方法再重新編譯,雖然編譯還是報如上同樣的錯誤,但安裝已能順利進行下去.

— Macro: LT_CONFIG_LTDL_DIR (directory)
Declare directory to be the location of the libltdl source files, for libtoolize --ltdl to place them.