Operations 6 min read

Guide to Installing and Configuring Keepalived for High Availability Using VRRP

This tutorial explains how to achieve high availability with keepalived by installing the software, configuring VRRP virtual IPs, setting up master and backup nodes, starting the service, and verifying failover through VIP testing on Linux systems.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Guide to Installing and Configuring Keepalived for High Availability Using VRRP

Part 1 – Introduction

High availability is a mandatory capability in many industries. keepalived implements the VRRP (Virtual Router Redundancy Protocol) to provide a simple, lightweight solution for node and service HA. This article walks through a basic experiment with keepalived.

vip : virtual IP , the meaning of a virtual IP address.

Part 2 – Network Setup

Two virtual machines each run a keepalived service. The VRRP protocol creates routing redundancy. By default the vip runs on the MASTER node, allowing clients to reach server-1 . If the master fails, the BACKUP node takes over the vip and serves server-2 .

Part 3 – Installing keepalived

1. Online installation

<code>yum install keepalived</code>

2. Offline installation

Download keepalived offline package

<code># 下载地址
https://www.keepalived.org/download.html</code>

Extract and install

<code>tar -zxvf keepalived-2.2.4.tar.gz
cd keepalived-2.2.4
./configure
# Install missing dependencies if prompted
make && make install</code>

Part 4 – Configuration

3. Disable firewalld

<code>systemctl stop firewalld
systemctl disable firewalld</code>

4. Edit keepalived configuration

Master node

vim /etc/keepalived/keepalived.conf

Backup node

vim /etc/keepalived/keepalived.conf

Parameter explanations

vrrp_strict – Enforces strict VRRP compliance; usually commented out.

state – Role of the node, can be MASTER or BACKUP .

priority – Determines priority; MASTER must have higher priority than BACKUP.

virtual_address – The virtual IP address (VIP); multiple addresses are allowed.

5. Start keepalived

On each node run:

<code>systemctl start keepalived</code>

6. Verify master‑backup relationship

If the configuration is correct, the MASTER node will acquire the VIP on its eth0 interface, while the BACKUP node will not have the VIP until a failover occurs.

Master keepalived start log

Backup keepalived start log

Part 5 – VIP Testing

A separate client VM accesses the vip to verify that the request is served by the MASTER node.

Before testing, a simple web service is started on both keepalived nodes to return a fixed string.

7. Failover test

The MASTER keepalived service is stopped, causing the BACKUP node to take over the VIP.

Backup logs show the transition to MASTER and the VIP moving to the backup node.

Client access to the VIP now reaches the new MASTER (previous backup) and returns the expected response.

Thus the keepalived tutorial is complete.

High AvailabilityLinuxSystem AdministrationfailovervrrpKeepalived
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login 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.