Mysql应用MySQL HandlerSocket插件安装配置教程
《Mysql应用MySQL HandlerSocket插件安装配置教程》要点: MYSQL必读一、HandlerSocket是什么? MYSQL必读目前使用MySQL的网站,多半同时使用Memcache作为键值缓存.虽然这样的架构极其流行,有众多成功的案例,但过于依赖Memcache,无形中让Memcache成为故障的根源: MYSQL必读注:关于清理过期数据的问题,可以在程序架构上想办法,如果数据操作有统一DAO封装的话,可以利用Observer模式来清理过期数据,非主题内容,资料自查. MYSQL必读面对以上问题,HandlerSocket项目是个不错的解决方案,它通过插件的方式赋予MySQL完整的NoSQL功能,从原理上讲,它跳过MySQL中最耗时的语法解析,查询计划等步骤,直接读取数据,如果内存够大,能装下索引,MySQL的查询效率能提高若干倍! MYSQL必读系统信息约定: yum install rpm-build gperf readline-devel ncurses-devel time perl-Time-HiRes MYSQL必读1. 安装 [root@iredmail opt]# git clone https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL.git [root@iredmail opt]# cd HandlerSocket-Plugin-for-MySQL [root@iredmail HandlerSocket-Plugin-for-MySQL]# ./autogen.sh [root@iredmail HandlerSocket-Plugin-for-MySQL]#./configure --prefix=/usr/local/webserver/handlersocket --with-mysql-source=/opt/mysql-5.5.20 --with-mysql-bindir=/usr/local/webserver/mysql5520/bin --with-mysql-plugindir=/usr/local/webserver/mysql5520/lib/mysql/plugin MYSQL必读Tips: +---------------+-------------------------------------------+ | Variable_name | Value???????????????????????????????????? | +---------------+-------------------------------------------+ | plugin_dir??? | /usr/local/webserver/mysql5520/lib/plugin | +---------------+-------------------------------------------+ 1 row in set (0.00 sec) [root@iredmail HandlerSocket-Plugin-for-MySQL]# make MYSQL必读常见错误: make[2]: *** [handlersocket.la] Error 1 make[2]: Leaving directory `/opt/HandlerSocket-Plugin-for-MySQL/handlersocket' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/opt/HandlerSocket-Plugin-for-MySQL' make: *** [all] Error 2 解决方法: [root@iredmail HandlerSocket-Plugin-for-MySQL]# vi handlersocket/Makefile line 301: $(handlersocket_la_LINK) -rpath $(pkgplugindir) $(handlersocket_la_OBJECTS) $(handlersocket_la_LIBADD) $(LIBS) --> $(handlersocket_la_LINK) -rpath /opt/HandlerSocket-Plugin-for-MySQL/handlersocket $( handlersocket_la_OBJECTS) $(handlersocket_la_LIBADD) $(LIBS) MYSQL必读[root@iredmail HandlerSocket-Plugin-for-MySQL]#make install 完成后,mysql-plugindir目录下应有handlersocket相关文件 MYSQL必读2、配置MySQL: [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. MYSQL必读Tips:InnoDB的innodb_buffer_pool_size,或MyISAM的key_buffy_size等关系到缓存索引的选项尽可能设置大一些,这样才能发挥HandlerSocket的潜力. MYSQL必读登陆MySQL并激活HandlerSocket插件: 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扩展文件,请查看扩展文件是否存在. mysql> install plugin handlersocket soname 'handlersocket.so'; Query OK,0 rows affected (0.00 sec) MYSQL必读mysql> quit; 至此,HandlerSocket插件安装完毕. MYSQL必读重启mysql服务: MYSQL必读3、HandlerSocket状态测试: |