High availability of a process between two Linux servers

Hello,

I would like to create a script that will maintain HA/failover of a process between two servers.

I wanted to send a continuous heartbeat message through a script to another server when everything is working fine, if a process has gone down then the same message should be sent another server then the slave server should bring up the process.

I have got no clue how to achieve this, please advice!

Thanks.

Hello Mahesh_RPM,

I have a few to questions pose in response first:-

  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Robin

Hey Robin,

I wrote a sample script to run in infinite loop and check the pid if it exists then create an ALIVE_master if not DOWN_master message in a logfile which will be synced to slave server using rsync every 2 mins, on the slave side there is a script to read the log file every 2 mins and see if its down then trigger the application start script if not stay alive.

so far its ok to send a message using log to slave but i want the same to be happend when Slave takes over which I'm not sure how to accomplish.

Please suggest if you have better idea.

I'm using Red Hat Enterprise Linux Server release 7.2 (Maipo) and I prefer to use Bash Script.

Thank you :slight_smile:

any clues yet?

Hi Mahesh,

doing HA with a simple shell-script may sound convenient for a first start, but a fast hacked together shell script is probably not at all what you want to do when you have HA in mind.

If you want to do it right, use corosync and pacemaker or some other HA-toolstack to build a stable cluster. That's not easy and requires considerable effort to learn, but it is a solid and stable solution.

A simple but far less hacky method than own shell scripts is using UCARP. UCARP is a small piece of software that hooks 2 or more servers together which check if each other is reachable. The "primary" node sets up the configured service ip and can launch an "up-script" after taking the service ip. So the connection between service-ip and service is a fairly good for such a type of easy-peasy-HA. I did that and the advantage of this is that UCARP is very easy to configure. The whole handling of who is master, who is slave and who is reachable and who not is done by UCARP.

1 Like