Sitemap
Beyond Localhost

Engineering that ships. War stories first: incidents, migrations, benchmarks and the on-call reality behind the slides. System design, infra, Kubernetes, backend. No hype, no product pitches. Want to write for us? Open the Write for Us tab.

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

10 min readJul 13, 2026

--

▶️ 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 port 3308 — 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.

--

--

DevOps voice
DevOps voice

Written by DevOps voice

17+ years of IT professional experience, focused on DevOps, DevSecOps, SRE, and cloud engineering. Goal is simple to make complex concepts easy to understand

Beyond Localhost
Beyond Localhost

Published in Beyond Localhost

Engineering that ships. War stories first: incidents, migrations, benchmarks and the on-call reality behind the slides. System design, infra, Kubernetes, backend. No hype, no product pitches. Want to write for us? Open the Write for Us tab.