Steps for Setting Up a Failover IP on Linode
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:
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
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.