mysql_proxy实现读写分离

代理服务器上的操作

wget http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-Proxy/mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit.tar.gz


mv  mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit.tar.gz /usr/local/


cd /usr/local/


tar xvf  mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit.tar.gz


mv  mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit mysql_proxy


echo"/usr/local/mysql_proxy/lib" >>/etc/ld.so.conf


service mysqld stop


cd /usr/local/mysql_proxy/bin


./mysql-proxy --proxy-backend-addresses=192.168.1.234:3306

--proxy-read-only-backend-addresses=192.168.1.134:3306

--proxy-lua-script=/usr/local/mysql_proxy/share/doc/mysql-proxy/rw-splitting.lua

--daemon

--user=mysql

--log-level=warning

--log-file=/var/log/mysql-proxy.log

--max-open-files=2048

--event-threads=4

--proxy-address=192.168.1.136:3306

 

 

主服务器234上的操作

grant all on *.* to min@'192.168.1.%'identified by '123456';(只要主操作就够了)

 

客户机上的操作(测试)

mysql -u min -h 192.168.1.136 -p123456 -e"show databases;"


mysql -u min -h 192.168.1.136 -p123456 -e"create database min;"

感谢一下博客的帮助

http://zhanglulu913.blog.51cto.com/10592685/1688947

你可能感兴趣的:(mysql,读写分离,mysql-proxy)