mysql> show variables like 'plugin%'; +---------------+-------------------------------------------+ | Variable_name | Value | +---------------+-------------------------------------------+ | plugin_dir | /usr/local/webserver/mysql5520/lib/plugin | +---------------+-------------------------------------------+ 1 row in set (0.00 sec) --phpfensi.com [root@iredmail HandlerSocket-Plugin-for-MySQL]# make 常见错误:
[root@iredmail HandlerSocket-Plugin-for-MySQL]# vi /etc/my.cnf [mysqld] plugin-load=handlersocket.so(plugin-load可略过不配) 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 concurren connections, make open_files_limit as large as possible. Tips:InnoDB的innodb_buffer_pool_size,或MyISAM的key_buffy_size等关系到缓存索引的选项尽可能设置大一些,这样才能发挥HandlerSocket的潜力.
登陆MySQL并激活HandlerSocket插件:
[root@iredmail HandlerSocket-Plugin-for-MySQL]# mysql -uroot -p mysql> install plugin handlersocket soname 'handlersocket.so'; ERROR 1126 (HY000): Can't open shared library '/usr/local/webserver/mysql5520/lib/plugin/handlersocket.so' (errno: 2 cannot open shared object file: No such file or directory) 说明:这里提示没有找到handlersocket.so扩展文件,请查看扩展文件是否存在.
[root@iredmail HandlerSocket-Plugin-for-MySQL]# service mysqld restart
HandlerSocket状态测试
也可以通过查询刚配置的端口是否已经被MySQL占用来确认是否安装成功:
[root@iredmail HandlerSocket-Plugin-for-MySQL]# lsof -i -P | grep mysqld --phpfensi.com mysqld 26871 mysql 11u IPv4 72467 0t0 TCP *:9998 (LISTEN) mysqld 26871 mysql 29u IPv4 72469 0t0 TCP *:9999 (LISTEN) mysqld 26871 mysql 31u IPv4 72474 0t0 TCP *:3306 (LISTEN) Tips:If ports 9998 and 9999 don’t show up. Make sure SELinux is not running. 安装配置 php-handlersocket 扩展模块,安装php-handlersocket扩展:
[root@iredmail opt]# wget http://php-handlersocket.googlecode.com/files/php-handlersocket-0.3.1.tar.gz [root@iredmail opt]# tar -zxvf php-handlersocket-0.3.1.tar.gz [root@iredmail opt]# cd handlersocket/ [root@iredmail handlersocket]# /usr/local/webserver/php5318/bin/phpize [root@iredmail handlersocket]# ./configure --with-php-config=/usr/local/webserver/php5318/bin/php-config ./configure可加参数: implemented configure options source file hsclient none (default) handlersocket.cc native --disable-handlersocket-hsclient handlersocet.c Tips:If you get an error: configure: error: Can't find hsclient headers,please install libhsclient first,Or ./configure--disable-handlersocket-hsclient --with-php-config=/usr/local/webserver/php5318/bin/php-config use native type. [root@iredmail handlersocket]#make && make install A successful install will have created handlersocket.so and put it into the PHP extensions directory. You'll need to and adjust php.ini and add an extension=handlersocket.so line before you can use the extension. [root@iredmail handlersocket]# vi /usr/local/webserver/php5318/etc/php.ini extension=handlersocket.so 至此php扩展安装完成,放问php.info页面,我们可以看到已经成功加载了handlersocket扩展.