Sharing IP addresses between two servers

0 like 0 dislike
5 views
There are two virtual servers with HAProxy posted on different physical machines, the task is to make the failover, ie to raise the IP address on the machine which is now available if the other stops responding.

All IP address from one pool, broadcast the same, but one machine does not see what the other sends, in broadcast, so solutions such as keepalived, ucarp, heartbeat not suitable. Why not see, do not know, but since no access to the network or to klenowski hypervisors that this side is nothing to fix. What else can you use to achieve the result without the broadcast? (To send in the broadcast is not a problem — still have to send ARP request blashemy to the router to change IP. The problem — read the other Itske of the broadcast).

Thank you.
by | 5 views

4 Answers

0 like 0 dislike
But all the same was faster and easier to write. Tell us more, for it is a good thing. I don't raspisyvaya as on different systems, but should work without problems on any redhat'about that.
\r
TK:
\r
two servers with the main yeskali 10.10.10.20 and 10.10.10.30
necessary third ipishka 10.10.10.40, which will rise on a live server if the other fell

\r
20 let the server be in charge, prescribe it in /etc/rc.local lifting alpiski and request to clear the cache::
\r
ifconfig eth0:1 10.10.10.40 netmask 255.255.255.0 arping -c 1-s 10.10.10.40 10.10.10.1

\r
Other 30 the server will be on support, if suddenly the first will refuse. It creates the script /usr/local/sbin/setupip inside:
\r
\r
#!/bin/bash MASTERHOST="10.10.10.20" IP1="10.10.10.40" MASK1="255.255.255.0" INERFACE1="eth0:1" GATE1="10.10.10.1" sleep 10 while true; do count=$(ping -c 1 $MASTERHOST | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') localip=$(ifconfig | grep "$IP1 " | wc-l) if [ $count -eq 0 ]; then if [ $localip -eq 0 ]; then #if the IP is not set - do add it, send ARP cache clear logger "setupip :: Host $MASTERHOST is down at $(date); Binding up $IP1" ifconfig $INERFACE1 $IP1 netmask $MASK1 arping -c 1-s $IP1 $GATE1 fi else if [ $localip -gt 0 ]; then logger "setupip :: Host $MASTERHOST is UP at $(date); Shutting down $IP1" ifconfig $INERFACE1 down fi fi sleep 10 done 

\r
Make it executable, put the script in /etc/rc.local to run at startup:
\r
/usr/local/sbin/setupip &

\r
Reboot. Everything is ready.
\r
\rThe result is:
\r
    \r
  • every 10 seconds the second server pings first
  • \r
  • if the first is the second raises the desired IP, cleans the ARP cache, and makes an entry in syslog (/var/log/messages)
  • \r
  • if the first rises, he runs at himself and cleaned the IP ARP cache from itself, and takes all request themselves
  • \r
  • the second sees that the first has risen, and puts IP at
  • \r

\r
All the tests ended well. Variables must be intuitive.
Think someone this script will be useful.
by
0 like 0 dislike
Something I think that the Bicycle invented long ago. One of the variants of this bike is called heartbeat one line config is written what is above is painted on half a page
by
0 like 0 dislike
It is called VRRP
\r
We advise to use keepalived
by
0 like 0 dislike
simple failover can be done on scripts service is allocated additional IP which is hung an alias on the interface is unavailable, and then lifted the service itself.
by

Related questions

110,608 questions
257,186 answers
0 comments
28,803 users