2

I have set a two node cluster on two RHEL7 virtual machines. I'm using pacemaker as my HA management software. I creates one resource for VIP and another resource for a shared FS. VIP and FS resources are working properly. However, I don't know how to let a specific service to failover like VIP and FS. I searched a lot but I can't find a way to do it. I have a script with three options to start,stop and get the status of my service. Now, I just want to add the service to my cluster, so if it went down on one node, it comes up on the other node. What I should use for that?

  • 1
    Usually you just [add that service via systemd or init scripts or or or](https://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/1.1/html/Pacemaker_Explained/s-resource-supported.html), what's the problem you are facing? – Lenniey Sep 12 '19 at 10:22

1 Answers1

4

There are a few ways to do this.

The best way, is to write your own OCF (Open Cluster Framework) resource agent as described in the OCF Resource Agent Developer’s Guide: http://www.linux-ha.org/doc/dev-guides/ra-dev-guide.html

You could also write a systemd unit file that starts your service, and then tell the cluster to control the service using that: # pcs resource create whatever systemd:<systemd-unit-name>

Lastly, there is an anything resource agent that you can use to launch Linux daemons. It seems like RedHat and CentOS do not provide this resource-agent in their latest resource-agents package (version 4.1.1). However, you can get it from ClusterLab's GitHub here: https://raw.githubusercontent.com/ClusterLabs/resource-agents/master/heartbeat/anything

One of those three should work for you. However, I would recommend taking the time to create a proper OCF resource agent for your service as described in the OCF RA Developer Guide linked above.

Matt Kereczman
  • 1,899
  • 9
  • 12
  • 3
    Quite frequently, the service to be managed already has a systemd unit. What's the advantage of writing an OCF resource agent? – Michael Hampton Sep 12 '19 at 18:09
  • 2
    @MichaelHampton an OCF agent can be more portable; you can feed it parameters from the Pacemaker config that'd you'd have to place in the services' "main" config file. Configuration and monitoring errors can be more specific; there are at least 9 non-zero return codes that Pacemaker understands, but with systemd all non-zero return codes would be treated equally. TLDR: a lot more granularity; just check the ToC on the RA dev guide and you'll get it: http://www.linux-ha.org/doc/dev-guides/ra-dev-guide.html. All that said, if a systemd unit exists, I will just use it 99.9% of the time :) – Matt Kereczman Sep 12 '19 at 20:18
  • @MichaelHampton Most important advantage of RAs is the ability to define parameters and documentation (via metadata). – U. Windl Feb 04 '21 at 11:27