handlersocket 安装配置
介绍:
"HandlerSocket is a MySQL plugin that implements a NoSQL protocol for MySQL. This allows applications to communicate more directly with MySQL storage engines, without the overhead associated with using SQL. This includes operations such as parsing and optimizing queries, as well as table handling operations (opening, locking, unlocking, closing). As a result, using HandlerSocket can provide much better performance for certain applications that using normal SQLapplication protocols."
handlersocket比memached好,没有memcached缓存的问题,可以通过该插件,将mysql扩展成一个nosql
纵观目前绝大部分大型互联网应用,基本上采用的都是Memcached+MySQL的方式。这是一种很成熟并且很有效的方式,基本都成了标准方式。由于HandlerSocket在Innodb Buffer Pool命中率很高的情况下性能不会逊色于Memcached,所以在这种情况下,可以采用HandlerSocket+MySQL来替代Memcached+MySQL。这样有以下几个优势:
1. 采用Memcached+MySQL,需要保存两份数据:Memcached和MySQL本身的缓存,需要双倍的内存资源。而HandlerSocket+MySQL的方式,只需要保存一份缓存数据。
2. 采用Memcached+MySQL,需要保持Memcached与MySQL的数据一致性,有时候可能会出现数据不一致的情况,而如果用HandlerSocket+MySQL就没这情况。
3. 采用Memcached+MySQL,还有一个这样的应用都非常小心和特别注意的问题,就是雪崩效应。新应用上线的时候需要先做好各种预热,尽量减少瞬间超级大的I/O压力。前段时间新浪微博出现一次比较严重的故障,据不完全可靠消息证实,就是雪崩效应引起的,当时有部分Memcached服务器出现故障或者失效,导致DB服务器压力瞬间增大,支撑不住。当然了,HandlerSocket应用不是不需要预热,也是需要的,但是在面对这样的问题的时候,它的支撑能力比起MySQL+Memcached的能力强。
1:安装
unzip HandlerSocket-Plugin-for-MySQL-master.zip
cd HandlerSocket-Plugin-for-MySQL-master
sh autogen.sh
./configure --with-mysql-source=/root/mysql-5.5.30 --with-mysql-bindir=/data/mysql/bin/ --with-mysql-plugindir=/data/mysql/lib/plugin
make
make install
##验证相关handlersock是否已经安装
[root@szl plugin]# ll handlersocket.*
-rw-r--r--. 1 root root 3564632 Mar 3 17:12 handlersocket.a
-rwxr-xr-x. 1 root root 971 Mar 3 17:12 handlersocket.la
lrwxrwxrwx. 1 root root 22 Mar 3 17:12 handlersocket.so -> handlersocket.so.0.0.0
lrwxrwxrwx. 1 root root 22 Mar 3 17:12 handlersocket.so.0 -> handlersocket.so.0.0.0
-rwxr-xr-x. 1 root root 1737376 Mar 3 17:12 handlersocket.so.0.0.0
[root@szl plugin]# pwd
/data/mysql/lib/plugin
显然已经安装!
##加载该插件
mysql -uroot -p'***' 登录,执行
install plugin handlersocket soname 'handlersocket.so';
然后执行show plugins;附件如下:
然后在/etc/my.cnf下的[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
重启mysqld,如果能正常启动,会在9999 和 9998 端口监听,见附件
show processlist;也会显示有handlersocket相关进程:
显然到此已经安装成功(需要进行防火墙配置)
php 需要使用 php-handlersocket插件连接handlersocket,
php-handlersocket插件安装方法如下:
cd handlersocket/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
在configure时遇到如下问题:
configure: error: Can't find hsclient headers
解决方法:
[root@zabbixserver handlersocket]# ./configure --disable-handlersocket-hsclient --with-php-config=/usr/bin/php-config
或安装libsclient,libsclient地址:
make
make install
cd /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525/lib
vi php.ini
在php.ini的最后加入:
extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525"
extension =handlersocket.so
并重启php-fpm服务,通过phpinfo();函数查看相关信息如下:
###percona的相关配置方法如下:
阅读(1119) | 评论(0) | 转发(0) |