Mastering Keepalived: Build a High‑Availability IPVS Cluster Step‑by‑Step
This guide explains keepalived’s VRRP‑based high‑availability architecture, details its core components, and provides a complete configuration walkthrough with diagrams, demonstrating how to set up a resilient IPVS load‑balancing cluster and verify failover behavior.
1. Introduction to keepalived
keepalived is an implementation of the VRRP protocol, originally designed for high‑availability IPVS services. It can generate IPVS rules from its configuration file and monitor the health of each real server. Using a shared virtual IP, only one master server provides service at a time; if it fails, another server takes over based on priority, ensuring high availability.
2. keepalived components
core : main process handling startup, maintenance, and global configuration.
vrrp stack : implements the VRRP protocol to provide high‑availability virtual IP services.
check : monitors the health of related processes.
system call : system calls used by the daemon.
watchdog : supervises the check and VRRP processes; when the check detects that the master service is unavailable, it notifies VRRP to shift to the backup server.
3. keepalived configuration
The experimental topology is shown below.
The main configuration file is divided into three sections: global_defs, vrrp_instance, and virtual_ipaddress. Edit /etc/keepalived/keepalived.conf on each node, adjusting priority and state as needed.
Configure Real Server1 and Real Server2 using the same method as lvs‑dr, provide test pages, and set up emergency response pages on the keepalived nodes.
After configuration, start keepalived and the backend hosts, then view IPVS information on the keepalived nodes.
Both nodes are now running keepalived.
Simulating a master node failure shows the virtual IP moving to the backup node, demonstrating address failover.
The test uses the round‑robin (RR) scheduling algorithm; results are shown below.
When a backend real server fails completely, the corresponding response and emergency pages are displayed, confirming that the high‑availability cluster works as expected.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
