Simple keepalived failover setup on Ubuntu 14.04

Table of Contents

We are going to set up very simple keepalived IP failover on Ubuntu 14.04. Keepalived is a piece of software which can be used to achieve high availability by assigning two or more nodes a virtual IP and monitoring those nodes, failing over when one goes down. Keepalived can do more, like load balancing and monitoring, but this tutorial focusses on a very simple setup, just IP failover.

Internally keepalived uses VRRP. The VRRP protocol ensures that one of participating nodes is master. The backup node(s) listens for multicast packets from a node with a higher priority. If the backup node fails to receive VRRP advertisements for a period longer than three times of the advertisement timer, the backup node takes the master state and assigns the configured IP(s) to itself. In case there are more than one backup nodes with the same priority, the one with the highest IP wins the election.

I'm also a fan of Corosync/Pacemaker, you can see my articles about Corosync here.

We'll install nginx and edit the default webpage, just to see where the IP is pointing to.

Requirements

You'll need the following to get started with keepalived:

2 servers in the same network

I'll be using Ubuntu 14.04 servers in this example. These servers are in the 10.32.75.0/24 network. The virtual IP will be 10.32.75.200.

The priority must be highest on the server you want to be the master/primary. It can be 150 on the master, and 100, 99, 98, 97 on the slaves. The virtual_router_id must be the same on all nodes and the auth_pass must also be the same. My network configuration is on eth0, change it if yours is on another one.

Configuring NGINX

For this example I have set up a very simple NGINX server with a very simple HTML page.