0

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.

  • I am wondering about the "backend - frontend" configuration for haproxy and the tcp keep alive... I do use only listen mysql-cluster bind 192.168.10.55:3306 mode tcp option mysql-check user haproxy_check balance roundrobin server percona-1 192.168.10.241:3306 check server percona-2 192.168.10.242:3306 check server percona-3 192.168.10.243:3306 check – Federico Galli Jun 22 '17 at 13:05
  • When I use this kind of configuration I recieve "haproxy.service: Start request repeated too quickly. Failed to start HAProxy Load Balancer." – O. Berdeha Jun 22 '17 at 13:16
  • haproxy -f /etc/haproxy/haproxy.cfg -c Configuration file is valid – O. Berdeha Jun 22 '17 at 13:23
0

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

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.