Operations 5 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Keepalived: Build a High‑Availability IPVS Cluster Step‑by‑Step

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.

keepalived components diagram
keepalived components diagram

3. keepalived configuration

The experimental topology is shown below.

experimental topology
experimental topology

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.

keepalived configuration example
keepalived configuration example
keepalived configuration example 2
keepalived configuration example 2

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.

real server configuration
real server configuration

After configuration, start keepalived and the backend hosts, then view IPVS information on the keepalived nodes.

IPVS information
IPVS information

Both nodes are now running keepalived.

both nodes running
both nodes running
additional status view
additional status view

Simulating a master node failure shows the virtual IP moving to the backup node, demonstrating address failover.

failover demonstration
failover demonstration

The test uses the round‑robin (RR) scheduling algorithm; results are shown below.

RR scheduling results
RR scheduling results

When a backend real server fails completely, the corresponding response and emergency pages are displayed, confirming that the high‑availability cluster works as expected.

failure demonstration
failure demonstration
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

IPVSkeepalived
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.