Operating System - HP-UX
1834643 Members
3427 Online
110069 Solutions
New Discussion

Package interdependencies

 
Eric Rellergert
Occasional Contributor

Package interdependencies

Is there a simple, straightforward way to make 2 or more separate packages dependent on one another in that if one of them fails over, the others do to? This way I can ensure that they are all running on the same node.
I remember someone mentioning this in the SG level 1 class I attended, but we didn't cover how to do it.
Any/all assistance would be greatly appreciated.
5 REPLIES 5
Sundar_7
Honored Contributor

Re: Package interdependencies

hmm..you can do this in couple of ways I guess

here is one version

Define the SERVICE_CMD in both the packages.

In PKG1

SERVICE_CMD=/etc/cmcluster/bin/monitor.sh pkg1/pkg1.conf

in PKG2

SERVICE_CMD=/etc/cmcluster/bin/monitor.sh pkg2/pkg2.conf

The monitor.sh loads the configuraion file for each of the packages from their directories (pkg1.conf and pkg2.conf).

In the pkg1.conf file, define the processes started by PKG1 AND PKG2.

In the pkg2.conf file define the processes started by PKG1 AND PKG2.

the monitor.sh should be written to be in a loop checking for the processes defined in the pkg1.conf and pkg2.conf files.

If any of the processes defined in the pkg1.conf or pkg2.conf fails then the script should exit with an error code of 1.

When the script that is defined as the SERVICE_CMD fails with the exit code of 1, the package manager automatically halt the package.

sounds good ?
Learn What to do ,How to do and more importantly When to do ?
Dave Olker
Neighborhood Moderator

Re: Package interdependencies

Hi Eric,

Another possible way to do this would be to make both packages depend upon the same EMS resource.

Chapter 6 of the "Managing Serviceguard Version A.11.16" manual, found here:

http://docs.hp.com/hpux/onlinedocs/B3936-90079/B3936-90079.html

contains a section called "Creating the Package Configuration". It talks about the configuration script used by the packages and how to specify Monitored Resources, that when become unavailable will cause a package to fail/migrate.

There is also a section called "Writing the Package Control Script" that talks about the "Customer Defined Functions" section of the scripts. You can use this customer defined section to control other packages in the cluster. The manual also has a section that details things to watch out for when you attempt to control one package from inside another package:

__________________________________

Adding Serviceguard Commands in Customer Defined Functions

You can add Serviceguard commands (such as cmmodpkg) in the Customer Defined Functions section of a package control script. However, these commands must not interact with the package itself. Additionally, if a Serviceguard command interacts with another package, then you need to check all packages with Serviceguard commands for the possibility of a command loop.

For instance, a command loop might occur under the following circumstances. Suppose Pkg1 does a cmmodpkg -d of Pkg2, and Pkg2 does a cmmodpkg -d of Pkg1. If both Pkg1 and Pkg2 start at the same time, Pkg1 tries to cmmodpkg Pkg2. However, that cmmodpkg command has to wait for Pkg2 startup to complete. Pkg2 tries to cmmodpkg Pkg1, but Pkg2 has to wait for Pkg1 startup to complete, thereby causing a command loop.

To avoid this situation, it is a good idea to always specify a RUN_SCRIPT_TIMEOUT and a HALT_SCRIPT_TIMEOUT for all packages, especially packages that use Serviceguard commands in their control scripts. If a timeout is not specified and your configuration has a command loop as described above, inconsistent results can occur, including a hung cluster.

______________________________________


Hope this gives you some ideas of how to do this.

Regards,

Dave


I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Carsten Krege
Honored Contributor

Re: Package interdependencies

Real package dependencies that can be configured in SG are planned for SG A.11.17 sometime 2005.

I wouldn't use EMS resources to define package dependencies. pkgmond resources are obtained through querying an SNMP MIB and SNMP uses the UDP protocol. I don't think it is a good idea to make your HA package dependent on the retrieval of a UDP message.

Defining a service script that executes "cmviewcl -p " in regular (but not too low!) intervals is more reliable and gives more information (where does the package run) and does not add another software into the picture.

Carsten
-------------------------------------------------------------------------------------------------
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
Gary L. Paveza, Jr.
Trusted Contributor

Re: Package interdependencies

I have a similiar requirement, except that I have 2 packages, one runs on each of 2 nodes at a time. In case of a production failover, the development package is shutdown and the production package takes over. If the development package fails, it determines where the production package is located and will not startup there.

I do this via the customer_defined_run_commands

For development:

customer_defined_run_commands includes this:

CURRENT_PROD_NODE=$(${CMVIEWCL} | ${GREP} | ${GREP} -v grep | ${AWK} '{print $5}')
${ECHO} "Current node is: ${CURRENT_PROD_NODE}"

CURRENT_HOST=$(${HOSTNAME})
${ECHO} "Current HOST is ${CURRENT_HOST}"

if [ "${CURRENT_PROD_NODE}" = "${CURRENT_HOST}" ]
then
${ECHO} "Cannot start package on ${CURRENT_HOST} due to "
${ECHO} "already running on this host"
${SLEEP} 10
$? = 1
test_return 8
fi


For production package:

customer_defined_run_commands includes:

CURRENT_DEV_NODE=$(${CMVIEWCL} | ${GREP} | ${GREP} -v grep | ${AWK} '{print $5}')
${ECHO} "Current node is : ${CURRENT_DEV_NODE}"

CURRENT_HOST=$(${HOSTNAME})
${ECHO} "Current HOST is ${CURRENT_HOST}"

if [ "${CURRENT_DEV_NODE}" = "${CURRENT_HOST}" ]
then
${ECHO}
${ECHO} "Shutting down in preparation for starting "
${ECHO}
${CMHALTPKG}
${SLEEP} 10
fi
Kent Ostby
Honored Contributor

Re: Package interdependencies

You could write a script in Package B that checks for a resource from Package A. If that resource disappears then the script dies and Package B fails as well.

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"