HandlerSocket 是MySQL的一个插件,用来实现 NoSQL 功能,用于跳过MySQL的SQL层面,直接访问内部的InnoDB存储引擎。
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.11-1.rhel4.i386.rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-devel-5.5.11-1.rhel4.i386.rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.11-1.rhel4.i386.rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-shared-5.5.11-1.rhel4.i386.rpm
rpm -ivh MySQL-client-5.5.11-1.rhel4.i386.rpm MySQL-devel-5.5.11-1.rhel4.i386.rpm MySQL-server-5.5.11-1.rhel4.i386.rpm MySQL-shared-5.5.11-1.rhel4.i386.rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.11.tar.gz
一、安装HandlerSocket
获取安装包:https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL.git
tar -zxvf ahiguti-HandlerSocket-Plugin-for-MySQL-1.0.6-73-g0e63366.tar.gz
cd ahiguti-HandlerSocket-Plugin-for-MySQL-0e63366/
./autogen.sh
./configure --with-mysql-source=/home/xinze/software/mysql-5.5.11 --with-mysql-bindir=/usr/bin --with-mysql-plugindir=/usr/lib/mysql/plugin
make && make install
修改/etc/my.cnf 配置
[mysqld]
plugin-load=handlersocket.so
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里加载HandlerSocket插件:
mysql> INSTALL PLUGIN handlersocket SONAME "handlersocket.so";
mysql>SHOW PLUGINS; # 查看插件是否加载成
mysql>SHOW PROCESSLIST; # 查看handlersocket是否正常运行
* 如果SHOW PROCESSLIST没有handlersocket 进程, 则先关闭SELinux后再试试看看。
* 在ubuntu下,可以先 /etc/init.d/apparmor stop 然后重启MySQL, 然后 /etc/init.d/apparmor start
二、安装 php-handlersocket 模块:
wget http://php-handlersocket.googlecode.com/files/php-handlersocket-0.1.0.tar.gz
tar zxvf php-handlersocket-0.1.0.tar.gz
cd php-handlersocket
phpize
./configure
make
make install