Sunday, January 7, 2018

Red Hat Cluster Part 4: Creating A Custom Script Resource

While configuring resources in a cluster, we add scripts for the services that are already present by default such as Apache, Oracle, NFS, File System and HA LVM. These script resources are used by the cluster services for management activities such as monitoring, starting, stopping, and restarting resources among nodes. In this blog we will perform a configuration test of a custom script resource.

If you are using RHEL or CentOS 7 for HA using pacemaker, then you have two options for creating a custom script resource, one is the LSB (Linux Standard Base) format and other is the OCF (Open Cluster Framework) format for the script. The resources created are in the OCF format by default. However, an LSB format resource script can be created for custom resource script.

Since, we are using RHEL 6, we are going to use LSB format. The location of this custom script will be /etc/init.d/. We will discuss the format, actions and return codes of the script below.

Script Actions:



Script exit status codes:

0   program is running or service is OK
1   program is dead and /var/run pid file exists
2   program is dead and /var/lock lock file exists
3   program is not running
4   program or service status is unknown
5-99   reserved for future LSB use
100-149   reserved for distribution use
150-199   reserved for application use
200-254   reserved

Error Codes:

1   generic or unspecified error (current practice)
2               invalid or excess argument(s)
3   unimplemented feature (for example, "reload")
4   user had insufficient privilege
5   program is not installed
6   program is not configured
7   program is not running
8-99   reserved for future LSB use
100-149    reserved for distribution use
150-199   reserved for application use
200-254   reserved

Now, we will configure a test script resource for managing a custom application. Create a custom LSB compliant script named Test_Resource.sh. Sample scripts can be found at GitHub.

Now, we add the resource in the cluster. We must use the script resource type:


We can add the resource in the service group:



On checking the cluster configuration, we can see that the script resource has been added:

           <resources>  
             <ip address="192.168.200.135/24" sleeptime="10"/>  
             <lvm lv_name="lv_test" name="CLVM" self_fence="1" vg_name="vg_test"/>  
             <fs device="/dev/vg_test/lv_test" force_unmount="1" fsid="24674" fstype="ext4" mountpoint="/TESTSERVER" name="Test Filesystem" options="rw" self_fence="1"/>  
             <script file="/etc/init.d/Test_Script" name="Test Script"/>  
         </resources>  
         <service domain="failover" name="Test Service" recovery="relocate">  
             <ip ref="192.168.200.135/24"/>  
             <lvm ref="CLVM"/>  
             <fs ref="Test Filesystem"/>  
             <script ref="Test Script"/>  
         </service>  

Reference: LSB refspecs

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.