HAProxy don’t balancing requests between nodes of Galera cluster

clustergalerahaproxyhigh-availabilitykeepalived

I stuck with the problem with balancing requests from app server to Galera cluster nodes.

The strukture of HA is

node1 10.62.10.35 (HAProxy + Keepalived) Master

node1 10.62.10.36 (HAProxy + Keepalived) Backup

node1 10.62.10.37 (HAProxy + Keepalived) Backup

Configuration of the Master Keepalived node1

global_defs {
router_id PSQL1
}
vrrp_script haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
vrrp_instance 50 {
virtual_router_id 50
advert_int 1
priority 101
state MASTER
interface ens160
virtual_ipaddress {
10.62.10.254/22 dev ens160
}
track_script {
haproxy
}
}

Configuration of the Backup Keepalived node2

global_defs {
router_id PSQL2
}
vrrp_script haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
vrrp_instance 50 {
virtual_router_id 50
advert_int 1
priority 3
state BACKUP
interface ens160
virtual_ipaddress {
10.62.10.254/22 dev ens160
}
track_script {
haproxy
}
}

Configuration of the Backup Keepalived node3 is the similar with the node2 except priority and router_id.

Configuration of the HAProxy is similar on each node

**`
frontend galera

    listen 10.62.10.254:3306
    mode tcp
    default_backend galera

frontend web

    bind *:8080
    mode http
    default_backend web

backend galera

    balance roundrobin
    option tcpka
    option mysql-check user haproxy_check
    server node1 10.62.10.35:3306 check weight 1
    server node2 10.62.10.36:3306 check weight 1
    server node3 10.62.10.37:3306 check weight 1

backend web

     mode http
     stats enable
     stats uri /
     stats realm Strictly\ Private
     stats auth Admin:admin
     stats auth Another_User:passwd

Keepalived works. If Master node is down (or keepalived/haproxy is stoped) then next backup node use 10.62.10.254 address. But when Master is alive and I stop only MYSQL on it HAproxy don't send requests to other nodes. When I stop Master keepalived, the Backup node also use only it local MYSQL server for requests.

Any suggestions?

Thanks for your replies and have a nice day.

Best Answer

I've found the solution. If you start haproxy and MYSQL on one server you need to change port 3306 to 3307 in frontend.

**` frontend galera

bind 10.62.10.254:3307
mode tcp
default_backend galera
Related Topic