ucarp basics

ucarp overview

ucarp is a method for a machine to use vrrp to 'advertise' that it 'owns' a particular IP address. Each machine sends out a vrrp message advertising that it can have that IP every X seconds. This is the 'advbase' (advertising base). Each machine sends a skew value with that vrrp message which is akin to its priority of holding that IP. This is the 'advskew' (advertising skew). Two machines both advertising at 1-second intervals (advbase=1), the one with the lower advskew will 'win'.

From the ucarp documentation:

Signals

Sending a SIGUSR1 to the carp process will log to syslog the status of carp.
Sending a SIGUSR2 to the carp process will attempt to demote the machine you're on if it is master

Install/configure

sub: May also be in /etc/sysconfig/carp/ now-adays

yum install ucarp
cd /etc/ucarp/
cp vip-common.conf vip-common.dist
      
vim vip-common.conf
# Common VIP settings which can be overridden in individual vip-.conf
# If you have extra options to add, see "ucarp --help" output
BIND_INTERFACE="eth0"
SOURCE_ADDRESS="10.1.80.181" # non-shared IP
PASSWORD="PASSWORD"
OPTIONS="--advskew 50 --shutdown --preempt"
      
vim /etc/ucarp/vip-001.conf
ID="001"
VIP_ADDRESS="10.1.80.180" # shared IP
      

The only differences between the primary machine's configurations and the secondary's are:

  1. advskew will be lower (numerically) on the primary.
  2. SOURCE_ADDRESS will be each machine's unique (always-theirs) IP.
chkconfig ucarp on
service ucarp start
      

To confirm things are working as expected - turn off the networking on the primary machine and verify that the secondary 'picks up':

tcpdump vrrp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
74:58:33.312636 IP carptest.example.com > vrrp.mcast.net: VRRPv2,
Advertisement, vrid 1, prio 50, authtype none, intvl 1s, length 36
74:58:34.505079 IP carptest.example.com > vrrp.mcast.net: VRRPv2,
Advertisement, vrid 1, prio 50, authtype none, intvl 1s, length 36
74:58:35.700066 IP carptest.example.com > vrrp.mcast.net: VRRPv2,
Advertisement, vrid 1, prio 50, authtype none, intvl 1s, length 36
74:58:36.895059 IP carptest.example.com > vrrp.mcast.net: VRRPv2,
Advertisement, vrid 1, prio 50, authtype none, intvl 1s, length 36
74:58:38.090053 IP carptest.example.com > vrrp.mcast.net: VRRPv2,
Advertisement, vrid 1, prio 50, authtype none, intvl 1s, length 36
74:58:39.285049 IP carptest.example.com > vrrp.mcast.net: VRRPv2,
Advertisement, vrid 1, prio 50, authtype none, intvl 1s, length 36