I have the following configurations for load balancing a precona cluster.
haproxy.cfg
global
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
#debug
#quiet
defaults
log global
mode http
option tcplog
option dontlognull
retries 3
maxconn 2000
timeout connect 3000
timeout server 5000
timeout client 5000
listen mysql-cluster
bind 127.0.0.1:3306
mode tcp
balance roundrobin
option mysql-check user root
server db01 192.168.54.158:3306 check
server db02 192.168.54.140:3306 check
I followed this tutorial to configure haproxy. However I'm unable to connect to the cluster from the haproxy instance.
mysql -u root -proot -h 127.0.0.1 --port=3306 -e "show variables like 'server_id'"
Throw the following error.
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
I tried to debug the issue by looking at the haproxy logs. However there wasn't any logs present in /var/log/syslog or there's no such file haproxy.log in /var/log/
I even tried updating /etc/rsyslog.d/49-haproxy.conf to the following and restarting rsyslog service
$ModLoad imudp
$UDPServerRun 514
local0.* -/var/log/haproxy-0.log
local1.* -/var/log/haproxy-1.log
&~
I'm using haproxy version 1.5.15 on ubuntu 14.04.1 LTS. I can directly connect to the mysql cluster from the haproxy node. What would have configured wrong here? How can I get the logging enabled properly in haproxy?
mysql -u root -proot -h 192.168.54.158 --port=3306 -e "show variables like 'server_id'"
does this work? Can you connect to the servers from the proxy machine? Would look like a connectivity issue. Also, you can activate the stats admin sock for haproxy and check the server status.