Member-only story
How to Build a Highly Available MySQL Setup with HAProxy and Keepalived
A step-by-step tutorial for load balancing two MySQL clusters through a single floating virtual IP, with automatic failover between two HAProxy nodes
▶️ YouTube , 📸 Instagram , 💼 LinkedIn , ✍️ Medium
Non-Member= Click HERE!
Introduction
A single load balancer is a single point of failure. If it goes down, it doesn’t matter how resilient your MySQL clusters are — nothing can reach them.
This guide walks through a production-style setup that removes that weak point:
- Two HAProxy nodes compiled from source and installed under a custom path
- Keepalived running VRRP between them, sharing one floating virtual IP (VIP)
- Two independent MySQL clusters — one on port
3306, one on port3308— each load balanced through its own HAProxy listener - systemd services for both HAProxy and Keepalived, so everything survives a reboot
- A working failover test so you know it actually works before you trust it in production
By the end, you’ll have a setup where either HAProxy node can go down and traffic keeps flowing through the VIP without a single manual step.





