Search code examples
mysqlload-balancinghaproxyfailoverrecovery

HAProxy for MySQL Master Slave Repliation


I need some advice on setting up HAProxy for MySQL master-slave replication cluster: I want all connections i.e. all reads and writes to go to the master and only if the Master fails should HAProxy forward the connections to the slave.

The HAProxy documentation isn't very clear on which balancing algorithm to use for this scenario. The way I figure it, using static-rr with very high weights for the master and the lowest weights for the slave is the closest I can get to configuring the scenario described above. But there is still a small chance that the slave gets the reads/writes even though the master is still up and healthy?

Which is the correct way to setup HAProxy for this strict master/slave setup? Is HAProxy the right tool to use or is there a better way to achieve this?


Solution

  • Use MaxScale from MariaDB. It is a real DB router. Easy to use and easy to configure. Is direct for MySQL/MariaDB or Galera Cluster.

    If you have more question we can chat