Load balancing Mariadb with HAProxy

Viewed 442

I have two Mariadb databases servers and wanted to on top it HAProxy, for load balancing. So that if one database goes down then another database should take the load.

My haproxy.cfg file

global
   log /dev/log local0
   chroot /var/lib/haproxy
   stats timeout 30s
   user haproxy
   group haproxy
   daemon

defaults
   log global
   option dontlognull
   option tcp-smart-accept
   option tcp-smart-connect
   option http-server-close
   option redispatch
   retries 3
   timeout http-request 10s
   timeout queue 1m
   timeout connect 10s
   timeout client 1m
   timeout server 1m
   timeout http-keep-alive 10s
   timeout check 10s
   maxconn 3000

listen haproxy_mariadb
   bind *:3306
   mode tcp
   balance roundrobin
   option httpchk
   option tcpka
   option mysql-check user jio_games_user
   server dbs01 192.168.53.4:3306 weight 1
   server dbs02 192.168.53.5:3306 weight 1

The above configuration work fine(check is not working with server).But I am unable to the stats page due to

 mode tcp

If I put below code then I am getting two section:

## HAProxy stats web gui.
listen stats
   bind *:80
   mode http
   stats enable
   stats uri /haproxy?stats
   stats realm HAProxy\ Statistics
   stats auth haproxy:haproxy
   stats admin if TRUE
   balance roundrobin
   server gdbs01 192.168.53.4:3306 check
   server gdbs02 192.168.53.5:3306 check

Then I am seeing two section on the statistics page, one for stats and another for haproxy_mariadb.

enter image description here

Please help me to get the statistics page only for 'haproxy_mariadb'.

Regards,

Dinesh Gupta

0 Answers
Related