Comments on How to setup HAProxy as Load Balancer for MariaDB on CentOS 7

In this tutorial, I will guide you trough the installation of a MariaDB Galera cluster on CentOS 7 which has an HAProxy load balancer in front. The total setup consists of 4 servers. I will use 3 CentOS 7 servers for the database nodes, 2 nodes will be active and 1 acts as the backup node. The fourth server will be used for the HAProxy load balancer. For the balance algorithm, we use leastconn (but you can use other algorithms).

10 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: kripz

Why it failed?

tail -f /var/log/haproxy-info.log 

Dec 18 22:56:17 localhost haproxy[4889]: Server mariadb_cluster/monyet_galera1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 1 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.

Dec 18 22:56:17 localhost haproxy[4889]: Server mariadb_cluster/monyet_galera2 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 1 backup servers left. Running on backup. 0 sessions active, 0 requeued, 0 remaining in queue.

 

Dec 18 22:56:18 localhost haproxy[4890]: Backup Server mariadb_cluster/monyet_galera3 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.

By: Cristian Balan

@kripz, a Firewall issue?

By: Cristian Balan

It would be useful to set two HAProxy servers for failover.

By: nebula

please add "wsrep_on=ON" to server.cnf

make sure listen mariadb_cluster 0.0.0.0:3030 (haproxy.cfg) and wsrep_cluster_name="mariadb_cluster" (server.cnf) is same

By: Nash

Hi everyone!I'm testing the Glaera Cluster, all its Ok but in the last step of Step 1 with /clustercheck command the system sais me this:

HTTP/1.1 503 Service Unavailable

Content-Type: text/plain

Connection: close

Content-Length: 44

 

The unique diference with your config its in "hosts" file i keep loopback localhost ip. Maybe this is the problem?Thanks a lot

By: krishan thisera

I had the same issue, it was username and password miss match, between database user we created for clustercheck and user in the script(/usr/bin/clustercheck).

By: John

on the very last step when i try to access galera through ha proxy i get this error;

ERROR 2003 (HY000): Cant connect to MySQL server on 'loadbalancerip address' (111 "connection refused).

I am using centos 7 on all nodes.

By: Sergio

Al intentar conectarme desde el haproxy a mariadb1 me sale error 2003 (hy000): can't connect to mysql server on ''(113 "no route to host")

By: Tomas

On my installation the config file in /etc/my.cnf.d/ was named server.cnf and not server.conf

By: Tomas

It seems like it's a typo in the clustercheckuser. The script /usr/bin/clustercheck uses user "-clustercheckuser" (with a dash) but the user created in database is without dash.

Br Tomas