I tried to configure mysql-proxy 0.8.2. There are two hosts behind it: M1 (10.10.10.1) and M2 (10.10.10.2).
There is a MySQL replication between M1 and M2. M1 is master, M2 is slave. All request what type is "write", forwarding to M1 correctly and replicate this record immediately from M1 to M2.
But if request type is "read", the proxy can't forward to M2, only to M1. I checked these packets with tcpdump, and I saw that every packet received on M1. The connection from proxy to MySQL servers are working perfectly checking with telnet & MySQL command.
When I shutdown the M1 server, all request (read/write) sent to another (M2) server. After M1 server is turned off, M2 is working well. Every record is available.
I don't understand why mysql-proxy is not forwarding the read packet to M2 too, while M1 is available. What is the problem? Or this is how it should normally run?
This is my config:
[mysql-proxy]
daemon = true
user = mysql
proxy-skip-profiling = true
keepalive = true
max-open-files = 2048
event-threads = 50
pid-file = /var/run/mysql-proxy.pid
log-file = /var/log/mysql-proxy.log
log-level = debug
admin-address = 10.10.10.5:4401
admin-username = admin
admin-password = xxxxxxx
proxy-address = 0.0.0.0:3307
proxy-read-only-backend-addresses = 10.10.10.2:3306
proxy-backend-addresses = 10.10.10.1:3306
plugin-dir=/usr/local/lib/mysql-proxy/plugins
plugins=proxy,admin,debug,replicant
LUA_PATH = /usr/lib/mysql-proxy/lua/proxy/?.lua
LUA_CPATH = /usr/lib/mysql-proxy/lua/?.so
admin-lua-script=/opt/mysql-proxy-0.8.2/admin.lua
proxy-lua-script=/usr/local/lib/mysql-proxy/lua/proxy/rw-splitting.lua
proxy-lua-script=/usr/local/lib/mysql-proxy/lua/proxy/balance.lua
proxy-lua-script=/opt/mysql-proxy-0.8.2/riporter.lua
There was some issues with that option in the past, but not in the version you're using.
The --proxy-read-only-backend-addresses will not cause the proxy to forward the read requests into the backends specified on that option.
For that, you'll need to change a lua script (or write a new one) that reads the read-only-backend-addresses option(s) and define the behaviour your want.
You can read more about this here.
Hope this gives you some clues for further research.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With