Usually, a Virtual IP is used to distribute the workload automatically among cluster nodes. Cisco uses HSRP to combine their routers in the Standby group with a single VIP assigned, which stands for the default gateway in a network. FreeBSD and Linux (Ubuntu, CentOS6, and Centos7) operating systems use CARP and UCARP respectively for this purpose.

The python script configures CARP for FreeBSD and UCARP for Linux machines automatically. While running from a CLI, please input the following data:

  • IP addresses for Master and Slave machines
  • Username and password for a superuser (root)
  • Virtual IP address
  • Preshared key to encrypt CARP/UCARP command flow

The configuration of Master/Slave is possible only between similar operating system – FreeBSD/FreeBSD, Ubuntu/Ubuntu, CentOS6/CentOS6 or CentOS7/CentOS7. Determination of the type of operating system is performed automatically.

The test environment consists of Ubuntu, CentOS6, CentOS7, FreeBSD servers in which the CARP/UCARP will be configured. Each type of OS has 2 machines.

ip-address-list

Only machines of one type of OS can be configured at a time.

carptopology

Note: The python script uses fabric library which requires BASH to be installed on all FreeBSD machines. Please use the following commands:


# pkg install -y bash
# echo "fdesc /dev/fd fdescfs rw 0 0" >> /etc/fstab ; mount -a
# chsh -s bash root ; cp /usr/local/bin/bash /bin/

Execute script to configure servers.

FreeBSD:

freebsd_success

Ubuntu:

ubuntu_success

CentOS6:

centos6_success

CentOS7:

centos7_success

You can test the system by shutting down the master node while pinging the VIP. Only one ping should be lost.

ping_result

If you try to use different types of operation systems for master and slave nodes, you will get the following notification and script will not perform the installation.
Try with FreeBSD and Ubuntu servers:

failed_bsd_ubuntu

Try with Ubuntu and CentOS6 server:

ubuntu-centos6

Try with CentOS6 and CentOS7 server:

cos6-cos7

Use the following commands to download and execute code files:

# git clone https://github.com/jamalshahverdiev/carp-ucarp-unix-linux.git
# cd carp-ucarp-unix-linux
# ./carp-ucarp.py

Advertisements