Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Simple failover cluster using UCARP on Ubuntu (Heartbeat Alternative)

Rumi, January 24, 2016

In this tutorial, I’ll show you the steps to create a simple failover cluster on Ubuntu using CARP. To make the things meaningful,we’ll create the cluster for Apache service but you can use it for any other service, which relay on IP.

Scenario:01

Here is my Setup:

PrimarySrv: This is the main server, where I configured the apache and which act as Master (IP: 192.168.1.202)
SecondarySrv: 2nd Apache Server where I configured the apache exactly like on PrimarySrv (IP : 192.168.1.203)
192.168.1.250 : Virtual IP address,created using Ucarp.

Ucarp is really simple, it works like this,when the PrimarySrv is up,it will assign the virtual IP 192.168.1.250 to it, in case that PrimarySrv is down then it will assign virtual IP to the SeconadrySrv and when the PrimarySrv will come online, it will assign the virtual IP once again to it.

I assume that you configured Apache server already according to the above scenario, Let’s test it for PrimarySrv:

02 03

For SecondarySrv:

Login to the servers and install Ucarp:

sudo apt-get install ucarp

04

05Edit the file /etc/network/interfaces on PrimarySrv:

sudo vi /etc/network/interfaces

06Change it according to your scenario:

# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.202
netmask 255.255.255.0

  #######################
  # ucarp configuration
  #######################
  # vid : The ID of the virtual server [1-255]
  ucarp-vid 1
  # vip : The virtual address
  ucarp-vip 192.168.1.250
  # password : A password used to encrypt Carp communications
  ucarp-password secret
  # advskew : Advertisement skew [1-255]
  ucarp-advskew 1
  # advbase : Interval in seconds that advertisements will occur
  ucarp-advbase 1
  # master : determine if this server is the master
  ucarp-master yes

# The carp network interface, on top of eth0
iface eth0:ucarp inet static
        address 192.168.1.250
        netmask 255.255.255.0

07Edit the file /etc/network/interfaces on SecondarySrv:

sudo vi /etc/network/interfaces

10 (1)Change it according to your scenario:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.203
netmask 255.255.255.0

 #########################
 # ucarp configuration
 #########################
 # vid : The ID of the virtual server [1-255]
 ucarp-vid 1
 # vip : The virtual address
 ucarp-vip 192.168.1.250
 # password : A password used to encrypt Carp communications
 ucarp-password secret
 # advskew : Advertisement skew [1-255]
 ucarp-advskew 100
 # advbase : Interval in seconds that advertisements will occur
 ucarp-advbase 1
 # master : determine if this server is the master
 ucarp-master no

# The carp network interface, on top of eth0
iface eth0:ucarp inet static
 address 192.168.1.250
 netmask 255.255.255.0

08Restart the network service on both servers:

sudo /etc/init.d/networking restart

09

10Check the IP configuration on both servers,you’ll see that the virtual IP(192.168.1.250) is assigned to the PrimarySrv:

ifconfig

11At this moment, SecondarySrv don’t know about the virtual IP,we can verify it:

ifconfig

12Now we access the apache web page in our web browser:

www.apache-cluser.local

13Note: http://www.apache-cluster.local is equal to 192.168.1.250

Shutdown the PrimarySrv server:

sudo poweroff

14Now,Ucarp assign the virtual IP (192.168.1.250) to the SecondarySrv server, let’s verify it:

ifconfig

15Access the apache web page in web browser once again:

www.apache-cluster.local

16

Once the PrimarySrv will be online, it will take the virtual IP back once again. For configuring the synchronization between the servers, please refer this tutorial.

Hope this will help you!

Src: https://rbgeek.wordpress.com/2012/09/02/simple-failover-cluster-using-ucarp-on-ubuntu/

Administrations Configurations (Linux) HeartbeatHighAvailibilityUCARP

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes