环境: 192.168.100.210
192.168.100.104
192.168.100.208
192.168.100.106
说明: 210,104作为mysql数据库.
208作为mysql-proxy.
106作为测试机器.
相关软件下载:
lua
www.lua.org
mysql-proxy
http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/
1. 在208上安装lua
#tar zxvf lua-5.1.4.tar.gz -C /usr/local
# cd /usr/local
#mv lua-5.1.4 lua
#cd lua
#make //make之后可以看到系统列表,下面的
命令要用到
#make linux //我这里是linux
#make install
2.安装mysql-proxy
# tar -zxvf mysql-proxy-0.6.0-linux-rhas4-x86.tar.gz -C /usr/local/
# cd /usr/local/
# mv mysql-proxy-0.6.0-linux-rhas4-x86 mysql-proxy
# export PATH=$PATH:/usr/local/mysql-proxy/sbin/
#mysql-proxy --proxy-read-only-backendaddresses=192.168.100.210:3306
--proxy-backend-addresses=192.168.100.104:3306
--proxy-lua-script=/home2/mysql-proxy-0.6.0-linux-rhas4-x86/share/mysql-proxy/rw-splitting.lua &
3.在210,104上设置权限
mysql> grant all privileges on backup.* to
[email=backup@'%']backup@'%'[/email]
identified by 'shenxun';
//这里给个账号backup,密码shenxun,读写操作的数据库是backup.
4.进行测试.
用106连接208的mysql-proxy:
/usr/bin/mysql -u backup -pshenxun