How To Install keepalived on Ubuntu 22.04

In this tutorial we learn how to install keepalived on Ubuntu 22.04. keepalived is Failover and monitoring daemon for LVS clusters

Introduction

In this tutorial we learn how to install keepalived on Ubuntu 22.04.

What is keepalived

keepalived is:

keepalived is used for monitoring real servers within a Linux Virtual Server (LVS) cluster. keepalived can be configured to remove real servers from the cluster pool if it stops responding, as well as send a notification email to make the admin aware of the service failure.

In addition, keepalived implements an independent Virtual Router Redundancy Protocol (VRRPv2; see rfc2338 for additional info) framework for director failover.

You need a kernel >= 2.4.28 or >= 2.6.11 for keepalived. See README.Debian for more information.

There are three methods to install keepalived on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install keepalived Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install keepalived using apt-get by running the following command:

sudo apt-get -y install keepalived

Install keepalived Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install keepalived using apt by running the following command:

sudo apt -y install keepalived

Install keepalived Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install keepalived using aptitude by running the following command:

sudo aptitude -y install keepalived

How To Uninstall keepalived on Ubuntu 22.04

To uninstall only the keepalived package we can use the following command:

sudo apt-get remove keepalived

Uninstall keepalived And Its Dependencies

To uninstall keepalived and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove keepalived

Remove keepalived Configurations and Data

To remove keepalived configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge keepalived

Remove keepalived configuration, data, and all of its dependencies

We can use the following command to remove keepalived configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge keepalived

References

Summary

In this tutorial we learn how to install keepalived package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.