Custom HA agent - Red Hat Linux Cluster

Hi experts, I have some custom application which I need to make Highly Available using red hat cluster service. How do I do it? i know in /usr/share/cluster i shall find HA agents for well known services like Apache or Sybase but I want to write HA agent for my own. I tried looking up on internet, and red hat documentation but couldn't find any systematic resource for the same. In system-config-cluster; I see a resource named script. Do I have to use this script resource for my custom application? If yes, I already did that. I wrote a script using apache.sh (found in /usr/share/cluster) and provided path of that script in resource config ( custom script is wrapper to start httpd daemon which bind to loop back address,stop this daemon and check its status). But i am unable to start it through cluster, i have added some ocf_log messages in script(for debugging) and they are not coming in /var/log/messages either. Any help, links, pointers would be greatly appreciated

Does the attached configuration guide for Red Hat clusters help?

Hi Neo

Cluster Admin Guide doesn't speak about setting up 'custom HA agent' or HA for custom applications.

Referring to this guide, i have successfully set up my 2-node red hat cluster; and have set up Apache service for HA

Now I want to learn or know how to make custom HA scripts, there is apache.sh in /usr/share/cluster and I was hoping to write my own using it, i did it as well however it seem not working.

I need some guidance as to how to achieve this(writing custom HA script), any inputs will be of great help.

Have you looked at the templates provided by Red Hat for writing custom failover scripts?

Hi fpmurphy

I looked in /usr/share/cluster/script.sh (and I think that's the template for custom app failover?). Here is how it looks like

#
# Script to handle a non-OCF script (e.g. a normal init-script)
#

LC_ALL=C
LANG=C
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export LC_ALL LANG PATH

. $(dirname $0)/ocf-shellfuncs

meta_data()
{
    cat <<EOT
<?xml version="1.0"?>
<resource-agent version="rgmanager 2.0" name="script">
    <version>1.0</version>
.....
}

case $1 in
        meta-data)
                meta_data
                exit 0
                ;;
        *)
                ;;
esac

[ -n "${OCF_RESKEY_file}" ] || exit $OCF_ERR_ARGS      # Invalid Argument
[ -f "${OCF_RESKEY_file}" ] || exit $OCF_ERR_INSTALLED # Program not installed
[ -x "${OCF_RESKEY_file}" ] || exit $OCF_ERR_GENERIC   # Generic error

# Don't need to catch return codes; this one will work.
ocf_log info "Executing ${OCF_RESKEY_file} $1"
${OCF_RESKEY_file} $1

declare -i rv=$?
if [ $rv -ne 0 ]; then
        ocf_log err "script:$OCF_RESKEY_name: $1 of $OCF_RESKEY_file failed (returned $rv)"
        exit $OCF_ERR_GENERIC
fi

Using above template i have created 'dummy_service.sh' and added status, start, stop, verify-all, monitor options in it (looking at apache.sh) to start, stop, monitor, verify my application is running (actually i am just trying to start httpd and stop it for now before going to more complex custom app)

If you like I can attach that script too.

Thanks

---------- Post updated 23-09-10 at 12:57 AM ---------- Previous update was 22-09-10 at 11:25 PM ----------

Alright it seems like 'script.sh' is not template for custom failover script

It is actually a resource agent for 'script' resource, in this script resource we need to provide path for /etc/init.d/<my script>

However this is a bit limiting, there are some unknown caveats like how to find out a node from which service is failed over (name of node on which service was previously running) and accessing shared resources (e.g. floating IP addresses)

---------- Post updated at 06:30 AM ---------- Previous update was at 12:57 AM ----------

I was able to set up custom HA agent; looking at few more options,

Thanks