1

I have my HAProxy running on VIP:192.168.61.32, also I've checked netstat -tulnp|grep 3306

 tcp    0    0   192.168.61.32:3306    0.0.0.0:*  LISTEN      7895/haproxy 

But when I run

mysql -h 192.168.61.32 -u root -p:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

HA-Proxy Nodes are at 192.168.61.30 & 192.168.61.31 & as I try connect to DB

root@haproxy1:~# mysql -h 192.168.61.30 -u root -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.61.30' (111)
root@haproxy1:~# mysql -h 192.168.61.31 -u root -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.61.31' (111)

My Backend Mysql Nodes are at 192.168.61.33 & 192.168.61.34, I'm able to Connect to them directly using

mysql -h 192.168.61.33 -u root -p

mysql -h 192.168.61.34 -u root -p

Configuration details of haproxy.conf:

global
        log /dev/log    local0
#       log /dev/log    local1 notice
        chroot /var/lib/haproxy
        user haproxy
        group haproxy
        daemon
        log 192.168.61.31 local0
        stats socket /var/lib/haproxy/stats
        maxconn 4000

defaults
        log     global
#       mode    http
#       option  httplog
        option  dontlognull
        contimeout 5000
        clitimeout 50000
        srvtimeout 50000
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http

listen stats 192.168.61.31:80
        mode http
        option  httplog
        stats enable
        stats uri /stats
        stats realm HAProxy\ Statistics
        stats auth admin:admin

listen galera 192.168.61.32:3306
               balance source
               mode tcp
               option tcpka
               option mysql-check user haproxy
               server mysql1 192.168.61.33:3306 check weight 1
               server mysql2 192.168.61.34:3306 check weight 1

Thats the configuration of my haproxy.conf in Second HA-Proxy Server, the first HA-Proxy Server Configuration is same except for the Ip Address in global & stats section is 192.168.61.30 [First HA-Proxy Server]

karthik v
  • 191
  • 2
  • 9

1 Answers1

1

The mistake I did was using wrong IP Addresses of my HA-Proxy Servers while granting privileges in mysqldb, once I gave right IP Addresses, it worked without any issues.

karthik v
  • 191
  • 2
  • 9