Monday, May 27, 2013

A virtual IP? What for? #linux

Layman's definition.
 It's an additional IP you assign to an interface by creating a virtual interface upon a real interface.

What for?
 For high availability scenarios, in which a service connects to a virtual IP pointing to a service (i.e. a database) .
1. The service breaks and a standby takes over bringing up the same virtual IP address automatically.
2. The application server reconnects to the standby as if nothing happened.

What kind of IP?
 Any available IP on the same network as the primary interface.


- An application server is associated to a database on
(address pointing to the database's virtual interface)
- The database server breaks down
- Bring down its virtual interface (if possible)
- On the standby server bring up the virtual interface with a virtual IP address.
ifconfig p2p1:0 inet netmask

- Refresh the arp cache on a neighbouring server (that in which the application making use of the service is hosted).
arping -U -w 1  -I p2p1

(no response is expected)

- From the same neighbour:

64 bytes from icmp_seq=1 ttl=64 time=0.538 ms
64 bytes from icmp_seq=2 ttl=64 time=0.318 ms
64 bytes from icmp_seq=3 ttl=64 time=0.320 ms
64 bytes from icmp_seq=4 ttl=64 time=0.623 ms
64 bytes from icmp_seq=5 ttl=64 time=0.278 ms
64 bytes from icmp_seq=6 ttl=64 time=0.287 ms
64 bytes from icmp_seq=7 ttl=64 time=0.197 ms
64 bytes from icmp_seq=8 ttl=64 time=0.280 ms

- Provided a standby database takes over as a part of a failover procedure, it must take over the same virtual IP.

- Care must be taken to make sure that the old database server's virtual interface gets brought down so it doesn't cause havoc (lookup the term STONITH)
- If using Dynamic Host Configuration Protocol make sure the virtual IP doesn't get assigned to any host automatically by restricting automatic leases to a lower range.


No comments:

Post a Comment