介绍一下我安装的步骤:
系统:centos5.5
1.源码安装mysql
省略,请baidu or google
2.安装HandlerSocket
下载地址:http://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/tarball/master
解压:
tar xvzfahiguti-HandlerSocket-Plugin-for-MySQL-1.0.6-23-g4cfc840.tar.gz
进入解压后的文件夹:
cd ahiguti-HandlerSocket-Plugin-for-MySQL-4cfc840/
自动生成编译脚本:
./autogen.sh
查看配置帮助:
./configrue --help
配置:
(--with-mysql-source:mysql源码目录
--with-mysql-bindir:mysql安装目录可执行程序文件夹
--with-mysql-plugindir:mysql插件目录)
./configure --prefix=/usr/local/HandlerSocket-Plugin--with-mysql-source=/root/source/mysql-5.1.53/--with-mysql-bindir=/usr/local/mysql/bin--with-mysql-plugindir=/usr/local/mysql/lib/mysql/plugin/
如果遇到这个错误:configure:error:cannot find macro directory `m4',请创建文件夹m4
mkdir m4
然后再执行配置命令;
如果提示mysql源码和mysql安装程序版本不一致,可能是源码版本有问题,可以看configure文件,mysql安装程序一般使用mysql_config--version,源码使用configure.in找到包含[MySQLServer]的一行,从中取出版本,有的configure.in没有该行或者被修改过都会出错,可以人工添加一行注释#[MySQLServer] 5.1.x(使用mysql_config看到的版本)
安装:
make && make install
3.为mysql添加该插件
配置:
修改
vi my.cnf
在[mysqld]下(一定是要在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.
以root登录mysql
mysql -hlocalhost -uroot -pxxxxx
安装插件:
mysql>install plugin handlersocket soname'handlersocket.so';
检查是否安装:
mysql>show processlist;
如果进程列表中有如下的,说明成功启动:
+----+-------------+-----------------+---------------+---------+------+-------------------------------------------+------------------+
| Id |User|Host|db| Command | Time |State|Info|
+----+-------------+-----------------+---------------+---------+------+-------------------------------------------+------------------+
| 1 | system user | connecting host |NULL| Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active |NULL|
| 2 | system user | connecting host |NULL| Connect | NULL | handlersocket: mode=rd, 0 conns, 0 active |NULL|
4.安装php模块
HandlerSocket文档中提供了三种方式安装:
http://openpear.org/package/Net_HandlerSocket暂时还没有时间测试,改天做完测试再贴出来……
http://github.com/tz-lom/HSPHP
http://code.google.com/p/php-handlersocket/
其中第一种pear方式安装成功(其实是移植perl的模块),第二种需要剥离PHPUnit代码,第三种模块编译成功(其实编译过程中也有很多问题,这里就不列出来了),但是load失败,会出现:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/modules/handlersocket.so' - /usr/local/php/lib/php/modules/handlersocket.so: undefined symbol: __cxa_pure_virtual in Unknown on line 0
这样的错误,如果谁知道如何解决,请分享~
参考文档:
http://hi.baidu.com/jgs2009/blog/item/25374adf77451a4495ee3727.html
http://www.gossamer-threads.com/lists/ntop/users/23342