1

I'm using HAProxy for mysql database backends. The database had to be master-slave. The goal is to point all mysql clients at the proxy and for all requests to go to mysql server #1 and only go to mysql server #2 if #1 is down.

There is an understanding and acceptance that when we are failed over to node 2, the database will be read only.

One thing I tried was setting the weight of node 1 to 256 and this kind of works but I don't want one out of 256 database calls going to node2; I need all calls to get directed to node1 unless node1 is actually down.

1

The answer is to use the check backup option to second backend node in the conf file like so:

listen mysql-cluster bind 0.0.0.0:3306 mode tcp option mysql-check user haproxy_check balance roundrobin server mysql-1 10.51.120.28:3306 check server mysql-2 10.51.123.25:3306 check backup

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.