linux之mysql57读写分离mysql-proxy
1 https://downloads.mysql.com/archives/proxy/ 去下载或者
https://cdn.mysql.com/archives/mysql-proxy/mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit.tar.gz
解压 tar -zxvf mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit.tar.gz
2 默认安装路径 /usr/local/mysql-proxy
默认 lua脚本 在 /usr/local/mysql-proxy/share/doc/mysql-proxy下
3 创建配置文件vim /etc/mysql-proxy.cnf
创建日志路径mkdir /usr/local/mysql-proxy/logs/ touch /usr/local/mysql-proxy/log/mysql-proxy.log
[mysql-proxy]
#用户
user=root
##mysql账号
admin-username=root
##mysql密码
admin-password=Yumeko213@
##当前ip 和端口
proxy-address=192.168.106.131:4040
##设置主库ip 和端口
proxy-backend-addresses=192.168.106.128:3306
##设置从库ip 和端口 多个从逗号
proxy-read-only-backend-addresses=192.178.168.129:3306
##采用自带的lua脚本
proxy-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
admin-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/admin-sql.lua
##设置日志
log-file=/usr/local/mysql-proxy/log/mysql-proxy.log
##设置级别
log-level=debug
##手动设置
daemon=true
##故障崩溃重启
keepalive=true
4 设置权限 chmod 660 /etc/mysql-proxy.cnf
5 修改lua的读写脚本中的最大值和最小值最小设置
vim /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
6 启动 mysql-proxy
cd /usr/local/mysql-proxy/bin
./mysql-proxy --defaults-file=/etc/mysql-proxy.cnf
7 测试外部链接工具