首先server1,server2,配置好主从关系
在server3中;
tar zxf mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz -C /usr/local/
cd /usr/local/
ln -s mysql-proxy-0.8.5-linux-el6-x86-64bit/ mysql-proxy
mkdir /usr/local/mysql-proxy/log
mkdir /usr/local/mysql-proxy/etc
cd mysql-proxy
vim etc/mysql-proxy.conf
cd /usr/local/
ln -s mysql-proxy-0.8.5-linux-el6-x86-64bit/ mysql-proxy
mkdir /usr/local/mysql-proxy/log
mkdir /usr/local/mysql-proxy/etc
cd mysql-proxy
vim etc/mysql-proxy.conf
user=root
daemon=true
keepalive=true
log-level=info
pid-file=/usr/local/mysql-proxy/log/mysql-proxy.pid
log-file=/usr/local/mysql-proxy/log/mysql-proxy.log
proxy-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
proxy-address=172.25.8.3:3306
proxy-backend-addresses=172.25.8.1:3306
proxy-read-only-backend-addresses=172.25.8.2:3306
plugins=proxy
daemon=true
keepalive=true
log-level=info
pid-file=/usr/local/mysql-proxy/log/mysql-proxy.pid
log-file=/usr/local/mysql-proxy/log/mysql-proxy.log
proxy-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
proxy-address=172.25.8.3:3306
proxy-backend-addresses=172.25.8.1:3306
proxy-read-only-backend-addresses=172.25.8.2:3306
plugins=proxy
chmod 660 etc/mysql-proxy.conf
vim share/doc/mysql-proxy/rw-splitting.lua
bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/etc/mysql-proxy.conf
更改lua脚本
netstat -antlp
vim share/doc/mysql-proxy/rw-splitting.lua
bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/etc/mysql-proxy.conf
更改lua脚本
netstat -antlp
server1,2,3,:
yum install lsof -y
lsof -i :3306
在server3:
在seerer2:
在server1:
yum install lsof -y
lsof -i :3306
在server3:
在seerer2:
在server1:
server1:
mysql> grant select,insert,update on westos.* to bss@'%' identified by 'Westos-123';
物理机
mysql -uproxy -p -h 172.25.8.3
MySQL [(none)]> use test;
MySQL [test]> select * from userlist;
MySQL [test]> insert into userlist values ('user3','666');
MySQL [test]> insert into userlist values ('user4','888');
MySQL [test]> select * from userlist;