The server is scheduled as follows:
192.168.100.128 Master
192.168.100.129 from
192.168.100.130 Mysql-proxy
1. Download and install the Mysql-proxy in 100.130
TAR-ZXVF mysql-proxy-0.8. 5-linux-el6-x86-64bit.tar.gzcp mysql-proxy-0.8. 5-linux-el6-x86-64bit/usr/local/mysql-proxy
2. Configure Environment variables
Lua_path="/usr/local/mysql-proxy/share/doc/mysql-proxy/?" Lua"export Lua_pathpath= $PATH:/usr/local/mysql-proxy/binexport java_home jre_home PATH CLASSPATH hadoop_home Lua_path
After saving exits
3. Modify the configuration of MySQL proxy's read-write separation script
Vim/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
if not proxy. Global . Config.rwsplit then Proxy. global. Config.rwsplit = { 1, // change to 1 2 , // change to 2 false } End
Default minimum 4 (maximum 8) More than the client connection will be realized read and write separation, now to the minimum 1 maximum 2, easy to read and write the test of separation
4. Create a user for the agent in 100.128,100.129
' Test ' @'192.168.100.130'321321 '
Mysql>flush privileges;
5. Start Mysql-proxy
vim/usr/local/mysql-proxy/mysql-proxy.sh // Create a new shell file and add the following :
The contents are as follows
Mysql-proxy--daemon--log-level=debug--log-file=/var/log/mysql-proxy.log--plugins=proxy-b192.168.100.128:3306-R192.168.100.129:3306--proxy-lua-script="/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua"--plugins=admin--admin-username="Test"--admin-password="321321"--admin-lua-script="/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua"
Note that there is no Admin.lua file by default in the "/usr/local/mysql-proxy/share/doc/mysql-proxy/" directory but there are Admin-sql.lua,
CP Admin-sql.lua Admin.lua
Start
./mysql-proxy.sh
It is important to note that user rights and firewalls are turned off
Use MySQL proxy to read and write a database