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 常見(jiàn)錯(cuò)誤:
[root@iredmail HandlerSocket-Plugin-for-MySQL]# vi /etc/my.cnf [mysqld] plugin-load=handlersocket.so(plugin-load可略過(guò)不配) loose_handlersocket_port = 9998 # 指定讀請(qǐng)求端口號(hào) # the port number to bind to (for read requests) loose_handlersocket_port_wr = 9999 # 指定寫(xiě)請(qǐng)求端口號(hào) # the port number to bind to (for write requests) loose_handlersocket_threads = 16 # 指定讀線(xiàn)程數(shù)目 # the number of worker threads (for read requests) loose_handlersocket_threads_wr = 1 # 指定寫(xiě)線(xiàn)程數(shù)目 # 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等關(guān)系到緩存索引的選項(xiàng)盡可能設(shè)置大一些,這樣才能發(fā)揮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) 說(shuō)明:這里提示沒(méi)有找到handlersocket.so擴(kuò)展文件,請(qǐng)查看擴(kuò)展文件是否存在.
[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 擴(kuò)展模塊,安裝php-handlersocket擴(kuò)展:
[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可加參數(shù): 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擴(kuò)展安裝完成,放問(wèn)php.info頁(yè)面,我們可以看到已經(jīng)成功加載了handlersocket擴(kuò)展.