MacにHandlerSocket-Plugin-for-MySQLを入れてみる

(1)ソースを落とす
https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL
からおとす。
gitは今回つかいませんでした。

(2)MySQLのソースをおとす
http://downloads.mysql.com/archives.php?p=mysql-5.5&v=5.5.6
ここから。
macportsでいれたMySQLが5.5.2-m2だったので
それにあわせてソースをおとす。

(3)コンパイル&インストール
(1)で落としたソースを展開したディレクトリで
$ ./autogen.sh
$ ./configure --with-mysql-source=/var/tmp/mysql-5.5.2-m2/ --with-mysql-bindir=/opt/local/bin --with-mysql-plugindir=/opt/local/lib/mysql5/mysql/plugin
が、エラー
macportsのmysqlはmysql5用にコマンド名の最後に5が入るため、configureが通らない。
そのため、シンボリックリンクをはって回避
$ sudo ln -s /opt/local/bin/mysql_config5 /opt/local/bin/msql_config

再度configureを実行。無事成功
$ make
$ sudo make install

(4)my.cnfの編集
つぎの記述を追加
[mysqld]
loose_handlersocket_port = 9998
# the port number to bind to (for read requests)
loose_handlersocket_port_wr = 9999
# the port number to bind to (for write requests)
loose_handlersocket_threads = 16
# the number of worker threads (for read requests)
loose_handlersocket_threads_wr = 1
# the number of worker threads (for write requests)
open_files_limit = 65535
# to allow handlersocket accept many concurrent
# connections, make open_files_limit as large as
# possible.

mysqlにてプラグインを認識させる
mysql> install plugin handlersocket soname 'handlersocket.so';

とりあえず、ここまで。

次回はPHPからHandlerSocket Pluginをつかってみます。