Search code examples
javalinuxfailover

Acquire failover system control


Dude, we have got two linux servers, which one of them is principal(main) and the another one is the agent.
Let's say the main server address is 1.1.1.1 and the agent is 2.2.2.2. For any reason(power, etc.) the main server would gets crashed.
Currently I monitor the main server by keeping a connection live between agent and main server.
I can identify and understand when the main server goes off.

The problem is I want to acquire the main ip address(1.1.1.1) by agent system to track and keep the clients requests, or redirect the client requests to another node.
Now how may I do this? both applications(servers) for agent and main servers are written by Java.
Thanks in advance :D


Solution

  • You can add an ethernet alias as eth0:1 or something on the interface where 2.2.2.2 (note: with these IP addresses you are borked because they are on different subnets, but since they are obviously bogus IP's I'll assume both machines are on the same subnet) is. E.g. if 2.2.2.2 is on eth0, create eth0:1 with IP address 1.1.1.1. Don't configure it to start (ONBOOT=no with RHEL initscripts). When main is down, do ifup eth0:1

    However, the "correct" answer is to use a HA stack - there are billions to choose from, and rolling your own will be vastly inferior.