Operations 7 min read

How to Build a Dual-Master LVS High‑Availability Cluster with Keepalived

This guide walks through the principles of Keepalived, its VRRP‑based architecture, and step‑by‑step configuration of a dual‑master LVS high‑availability cluster, covering prerequisites, installation, keepalived setup, real server configuration, testing failover, and handling complete node failures.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Build a Dual-Master LVS High‑Availability Cluster with Keepalived

Introduction

Based on Keepalived, this article explains how to implement an LVS dual‑master high‑availability cluster. Keepalived ensures services stay online by providing high availability or hot‑standby, preventing single‑point failures.

Keepalived Overview

Keepalived uses the Virtual Router Redundancy Protocol (VRRP) to achieve software‑based multi‑node hot‑standby on Linux. A VRRP group shares a virtual IP; only one master serves traffic while others stay redundant, ready to take over based on priority.

How It Works

Core : launches and maintains the main process, loads global configuration. Check : performs health checks (HTTP, LVS, etc.) and parses related configs. VRRP : implements the VRRP protocol for failover. libip* : provides LVS‑related functionality.

High‑Availability Solution

Experimental Topology

Configuration Process

Prerequisites: time synchronization, hostname‑based communication, SSH trust.

Ensure both nodes have synchronized time (e.g., using ntpdate).

Hostname Communication

SSH Trust

Install Required Programs

Configure Keepalived

Sync Configuration to the Other Node

Modify Configuration on the Second Node

Real Server Configuration

Kernel Parameters and VIP

Prepare Test Page

Test Page

Keepalived Node Emergency Page

Start Keepalived

Check IP and IPVS Rules on Both Nodes

Access Test

Simulate Master Node Failure

Check IP and IPVS Rules Again

After a master node goes down, all VIPs and IPVS rules migrate to the remaining node, so service access is uninterrupted. When the failed node returns, resources shift back automatically.

Simulate All Real Servers Failure

We then bring down both real‑server nodes to verify that the sorry_server takes over.

View IPVS Rules

Sorry Server Comes Online

The sorry_server responds successfully, completing the Keepalived‑based LVS dual‑master high‑availability experiment.

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.

high availabilityLinuxClusterLVS
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.