HandlerSocket安装
1、下载HandlerSocket
https://github.com/DeNA/HandlerSocket-Plugin-for-MySQL
2、查看你服务器mysql的版本,下载对应的源代码包并解压
3、安装HandleSocket
unzip HandlerSocket-Plugin-for-MySQL-master .zip
./autogen.sh
./configure --with-mysql-source=/root/mysql-5.6.26/ --with-mysql-bindir=/home/mysql/mysql/bin/ --with-mysql-plugindir=/home/mysql/mysql/lib/plugin/
其中:
--with-mysql-source:指定MySQL源码所在目录
--with-mysql-bindir:指定mysql_config所在目录
--with-mysql-plugindir:指定MySQL插件的存储路径
执行make编译安装:
make && make install
4、mysql相关设置
(1)将下面写入my.cnf中,重启数据库
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
innodb_buffer_pool_size=1024M
innodb_log_file_size=512M
innodb_log_files_in_group = 3
open_files_limit = 65535
innodb_adaptive_hash_index=1
(2)在mysql里加载HandlerSocket插件:
mysql>install plugin handlersocket SONAME 'handlersocket.so';
mysql>show plugins;#查看插件是否加载成功。
5、查看端口
lsof -i -P|grep mysql
mysqld 2646 mysql 17u IPv4 14234 0t0 TCP *:9998 (LISTEN)
mysqld 2646 mysql 35u IPv4 14257 0t0 TCP *:9999 (LISTEN)
mysqld 2646 mysql 37u IPv6 14272 0t0 TCP *:3306 (LISTEN)