Linode Forum Index Linode Forum
Linode Community Forums
 


Steps for Setting Up a Failover IP on Linode

Click here to go to the original topic

 
       Linode Forum Index -> Linux Tips, Tricks, Tutorials
Author Message
acouch



Joined: 15 Nov 2009
Posts: 4
Location: Philadelphia, PA

Posted: Thu Jan 28, 2010 2:19 pm    Post subject: 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

Code: 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

Code: 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:

Code: ifdown eth0:1

Turn on eth0:1 on Server B:

Code: ifup eth0:1

Send out a gratuitous arp request on Server B:

Code: 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?
Back to top  
vds



Joined: 27 Apr 2010
Posts: 8

Posted: Fri May 07, 2010 12:31 pm    Post subject:  

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.
Back to top  
acouch



Joined: 15 Nov 2009
Posts: 4
Location: Philadelphia, PA

Posted: Mon May 10, 2010 10:28 am    Post subject:  

thanks. glad it was helpful. i've expanded it here: http://www.zivtech.com/blog/setting-basic-ip-failover-using-ubuntu-linode
Back to top  
z8000



Joined: 26 Jul 2009
Posts: 19

Posted: Mon Apr 18, 2011 10:09 am    Post subject:  

You have 'auto eth0:1' on both hosts. What if they are both rebooted?
Back to top  
 
       Linode Forum Index -> Linux Tips, Tricks, Tutorials
Page 1 of 1