Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have two identical storage hosts where the master is the only one the users can access. If the master fails, then I want to manually change the DHCP address, so instead of master points to 10.10.10.10 it should point to 10.10.10.11.

There are replication scripts that rely on IP addresses, so if the master changes IP address, then I have to modify the IP in the scripts, so the data is still replicated from the master to the slave.

Question

It is quite an error prone task to switch IP adresses and edit scripts. Is there an common practice how this sort of manual failover is done? E.g. by adding an abstraction layer of some sort?

share|improve this question
4  
Commonly competent sysadmins are used –  Iain Jan 16 at 10:38

2 Answers 2

up vote 13 down vote accepted

The common practice is to have a separate IP address and name for the service, one that is separate from the actual server's IP address and name.

In this case, you have

master 10.10.10.10
slave  10.10.10.11

A third name could be

storage 10.10.10.12

Your clients should use "storage" instead of "master" when they connect to the service.

As long as master is online, then 10.10.10.12 should be a virtual interface on master. If master is down, bring 10.10.10.12 up as a virtual interface on slave.

Avoid using IP addresses in scripts as far as possible. If DNS lookups aren't an option in a particular case, use a config file or the /etc/hosts files to map hostnames to IP addresses.

share|improve this answer
1  
+100, if I could, for "avoid using IP addresses in scripts as far as possible". The troubles I've seen caused by that practice, over the years. –  MadHatter Jan 16 at 10:34
1  
@MadHatter I see your script and raise you "hardcoded into binaries and lost the source code". I ended up editing the binaries in-place, replacing an IP address with a string that we resolved in /etc/hosts... That was a fun night. –  Jenny D Jan 16 at 10:38
1  
I fold, mostly in admiration. –  MadHatter Jan 16 at 10:59
1  
Admiration was not the feeling I was having... –  Jenny D Jan 16 at 11:01

If you would like a more automatic solution for failover then look at something like keepalived with uses the VRRP protocol.

More information can be found here

Virtual IP 10.10.10.10 (This is a virtual IP address and is configured on both hosts)

Master IP 10.10.10.11

Slave IP 10.10.10.12

This way you will not have to bring up the second interface on the slave and you have very little (maybe a second or so ) of downtime.

share|improve this answer
    
This is automatic failover, which is not what I want. I use ucarp on other servers though. –  Sandra Jan 16 at 11:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.