Steps for Setting Up a Failover IP on Linode

I spent some time on this so wanted to share what I've learned, but also get feedback on a couple of items. It would be great if folks could take a look and let me know if this is correct.

Goal:

Have a basic IP failover without the overhead or automation of Heartbeat.

If a site goes down I want to have a script that will allow another server to grab the active IP address. I don't want to automate this so I can do a basic check before flipping the switch. If is a problem with the site switching servers will not necessarily solve anything.

Setup:

Server A with IP 1

Server B with IP 2

Swap IP 3

LAMP stack with Drupal site.

Pre Step:

1) Make sure apache and php settings are identical

2) Setup master / slave replication. Server A is master.

3) Setup identical files on Server A and B using rysnc and svn.

Steps to Setup Failover on Linode

1) Purchase additional IP address (IP 3) for Server A

2) Add IP 3 as a Failover for Server B: https://www.linode.com/members/linode/ipfailover.cfm

3) Add IP 3 as Eth0:1 on Server A and Server B

for Server A:

vim /etc/network/interfaces

auto eth0
iface eth0 inet static
  address 'IP 1'
  gateway 'IP 1 gateway'
  netmask 255.255.255.0

auto eth0:1
iface eth0:1 inet static
  address 'IP 3'
  gateway 'IP 3 gateway'
  netmask 255.255.255.0

for Server B:

vim /etc/network/interfaces

auto eth0
iface eth0 inet static
  address 'IP 2'
  gateway 'IP 2 gateway'
  netmask 255.255.255.0

auto eth0:1
iface eth0:1 inet static
  address 'IP 3'
  gateway 'IP 3 gateway'
  netmask 255.255.255.0

You can find the gateway information on your networking tab in your Linode account.

Restart networking on Server A.

Make sure Eth0:1 is setup correctly using 'ifconfig'.

4) Direct traffic for examplesite.com to 'IP 3'

You can do this through the Linode DNS manager.

5) Test switching traffic from Server A to Server B

Turn off eth0:1 on Server A:

ifdown eth0:1

Turn on eth0:1 on Server B:

ifup eth0:1

Send out a gratuitous arp request on Server B:

arping -I eth0:1 'IP 3' -uc 5

update /etc/hosts files on both servers to include their IP and reverse dns

6) Profit?

I would setup a script that would do the steps in '5'. I would also stop the mysql slave and rsync on Server B. This has worked during a test run.

Questions

a) Am I arping correctly? Everywhere I see documentation about this it says to use "arping -I -U 'IP'" but when I try to use that it gives a description of the usage. This is the 'ARPing 2.06' package I get on Ubuntu 9.10 which is installed through 'apt-get install arping'

b) The first time I tested this it took at least an hour to update. But once it did the first time using the steps in 5 the change was almost instant. Is the MAC address getting cached somewhere else than the ARP table? Is the ARP table not getting updated?

3 Replies

What a great post!

I m newbie and unable to answer your question.

But appreciate this tutorial.

I have tried to dig this forum for setting up HA on my linode(s). And this is the best post I have ever found.

thanks. glad it was helpful. i've expanded it here: http://www.zivtech.com/blog/setting-bas … ntu-linode">http://www.zivtech.com/blog/setting-basic-ip-failover-using-ubuntu-linode

You have 'auto eth0:1' on both hosts. What if they are both rebooted?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct