First use one as read/write, and one as read-only
Mysql-proxy -- proxy-address = 192.168.210.20.: 3306 -- proxy-read-only-backend-addresses = 192.168.210.132: 3306 -- proxy-backend-addresses = 192.168.210.131: 3306 -- proxy-lua-script =/usr/local/share/mysql-proxy/rw-splitting.lua>/var/log/mysql-proxy/mysql-proxy.log &
Currently, one read/write instance is used. The other two are read-only instances.
Mysql-proxy -- proxy-address = 192.168.210.20.: 3306 -- proxy-read-only-backend-addresses = 192.168.210.131: 3306 -- proxy-read-only-backend-addresses = 192.168.210.132: 3306 -- proxy-backend-addresses = 192.168.210.134: 3306 -- proxy-lua-script =/usr/local/share/mysql-proxy/rw-splitting.lua>/var/log/mysql-proxy/mysql-proxy.log &
Summary
1. In case of different sessions of the same IP address, the Proxy will be counted as a client, that is, each IP address is a CLIENT, rather than the actual number of connections.
2. the parameter that controls the triggering of read/write splitting is located in/usr/local/share/mysql-proxy/rw-splitting.lua script min_idle_connections. when the number of connections on the client exceeds this value, Proxy read/write splitting starts. (currently, the max_idle_connections parameter has no special effect)
3.-proxy-read-only-backend-addresses can be added. However, the test is always connected to the first added server. Automatic request distribution is not performed.