Let's say if I have two mysql databases, db1 and db2. Is that possible to configure haproxy to work like that:

  1. In the beginning: db1 work as master and db2 as backup.
  2. The haproxy will promote db2 as master when db1 is down.
  3. The haproxy will not use db1 even when db1 is recovered.
  4. The haproxy will promote db1 as master again when db2 is down.

I have read some answers in stackoverflow. But they only figure out the first 3 requirements. ( such as HAProxy switch only in case of server down )

Thank you for your time.

PS: My Platform: Redhat Haproxy Version: 1.5.2


You can use a stick table in HAProxy and the tips used in this blog article: http://blog.haproxy.com/2014/01/17/emulating-activepassing-application-clustering-with-haproxy/

It describes how to fix your 4 points.


| improve this answer | |

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.