I am trying to use HAProxy as a load balancer for 2 mysql nodes. I have HAProxy listening on 3307 and it routes requests to the DBs on 3306. When the client is trying to connect to the Proxy (mysql -u ... -h .. -P3307 -p...) it gets the following error:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system >error: 0
When the client is trying to connect directly to the DB it works fine. I have no idea why its failing when traffic goes via the Proxy.
Here's what I've already checked:
/etc/hosts.allow includes "mysqld: ALL : allow "
MySQL config file (my.cnf) doesn't have a bind address line (open to all).
I am using HAProxy 1.5dev, Mysql 5.1.x and the whole enchilada is running in ec2 on Amazon linux.
Here's the HAProxy config file:
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info user haproxy group haproxy maxconn 4096 daemon #debug #quiet defaults log global mode tcp option tcplog option dontlognull retries 3 option redispatch maxconn 4096 contimeout 5000 clitimeout 50000 srvtimeout 50000 frontend mysql_cluster bind 10.0.0.150:3307 default_backend mysql_cluster backend mysql_cluster mode tcp balance roundrobin option tcpka option httpchk server lb1 10.0.0.140:3306 check port 9200 inter 5s rise 2 fall 2 server lb2 10.0.0.214:3306 check port 9200 inter 5s rise 2 fall 2 listen stats 10.0.0.150:8081 mode http option httpclose balance roundrobin stats uri / stats realm Haproxy\ Statistics stats auth ***:***
Has anyone tackled this problem before? Any ideas how to solve this?
Any help much appreciated