HAProxy and MySQL Checks

HAProxy and MySQL Checks

I wanted to throw this out in case anyone else has a need for such a setup to use L7 for node up/down when load balancing MySQL with HAProxy.
All you have to do is run the following script. Copy the content below into setup_chkmysql.sh

nano setup_chkmysql.sh

Copy contents from below, save and exit.

chmod +x setup_chkmysql.sh
sudo ./setup_chkmysql.sh

Now add the following for you haproxy.cfg file on your load balancer.

frontend mysql-3306
        mode tcp
        log global
        option tcplog
        timeout client 60000ms
        default_backend mysql_tcp

backend mysql_tcp
        balance leastconn
        timeout connect 60000ms
        timeout server 60000ms
        option httpchk
        option allbackups
        default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 256 maxqueue 128 weight 100
        server galera-1 galera-1.everythingshouldbevirtual.local:3306 check
        server galera-2 galera-2.everythingshouldbevirtual.local:3306 check
        server galera-3 galera-3.everythingshouldbevirtual.local:3306 check


Leave a Reply

Your email address will not be published. Required fields are marked *