25.9.5 Service creation and registration

This section provides an overview of Sun Cluster's service control and explains how to register HiRDB as a data service in the Sun Cluster environment using a Sun Cluster control script.

Organization of this subsection
(1) Sun Cluster's service control specification
(2) Methods
(3) HiRDB data service control script (Sun Cluster control script)
(4) HiRDB data service registration

(1) Sun Cluster's service control specification

Use HA-API to register HiRDB as a data service in the Sun Cluster environment. Available APIs include data service registration (hareg), cluster status check (haget), etc. For details, see the Sun Cluster documentation.

(2) Methods

A method refers to a call-out to a data service that occurs in each step during reconfiguration. The following methods are available:

For the HiRDB data service, register the control scripts that will be called when the Start (START, START_NET) and Stop (STOP, STOP_NET) methods occur.

(3) HiRDB data service control script (Sun Cluster control script)

To set up the HiRDB environment as a data service in the Sun Cluster environment, execution control using Sun Cluster HA-API must be carried out. This section explains an example of creating Sun Cluster control scripts for controlling the calling of methods from Sun Cluster. The following names are used for the Sun Cluster control scripts to be created:

Script to be executed by START_NET

#!/bin/sh
## *********************************************************************
##  HiRDB START_NET Control Script (for Sun Cluster)
## *********************************************************************
PATH=/sbin:/usr/bin:/usr/sbin:/etc:/bin:/opt/SUNWcluster/bin:/HiRDB_S1/bin
export PATH
PDDIR=/HiRDB_S1
PDCONFPATH=/HiRDB_S1/conf
LD_LIBRARY_PATH=/HiRDB_S1/lib
export PDDIR PDCONFPATH LD_LIBRARY_PATH

if [ "$1" != "sc-lnode0" ]
then
  exit 0
fi

$PDDIR/bin/pdstart

Script to be executed by STOP_NET

#!/bin/sh
## *********************************************************************
##  HiRDB STOP_NET Control Script (for Sun Cluster)
## *********************************************************************
PATH=/sbin:/usr/bin:/usr/sbin:/etc:/bin:/opt/SUNWcluster/bin:/HiRDB_S1/bin
export PATH
PDDIR=/HiRDB_S1
PDCONFPATH=/HiRDB_S1/conf
LD_LIBRARY_PATH=/HiRDB_S1/lib

export PDDIR PDCONFPATH LD_LIBRARY_PATH

if [ "$2" != "sc-lnode0" ]
then
  exit 0
fi

MASTER_HOST=`haget -f master -h sc-lnode0`
if [ $MASTER_HOST != `hostname` ]
then
   exit 0
fi

$PDDIR/bin/pdstop -f -q*

Note
The control scripts created above must be stored in the same directory as the HiRDB system definition files ($PDDIR/conf). For nodes other than the master node as well, the same files must be stored in the same directory.
* Executing this command may cause an error shutdown in the RDAREAs on the shared disk. If this happens, use the database recovery utility to recover the RDAREAs on the shared disk.

(4) HiRDB data service registration

Use Sun Cluster's hareg command to register the HiRDB data service hirdb00 into the logical host.

hareg -r hirdb00 -b "/HiRDB_S1/conf"
 -m START_NET="hirdb00-start_net.sh" -t START_NET=1800
 -m STOP_NET="hirdb00-stop_net.sh"   -t STOP_NET=300
 -h sc-lnode0 -a 1

Explanation
-r: Specifies the data service name; this name must be unique within the cluster.
-b: Specifies the directory for storing the control script file.
-m: Specifies START_NET="HiRDB-startup-control-script-file-name".
-t:START_NET=1800
Specifies in seconds the amount of time for terminating the action of the HiRDB startup control script. Specify at least 1800 seconds.
-m: Specifies STOP_NET="HiRDB-stop-control-script-file-name".
-t: STOP_NET=300
Specifies in seconds the amount of time for terminating the action of the HiRDB stop control script. Specify around 300 seconds.
-h: Specifies the name of the logical host.
-a: Specifies the HA-API version (specify 1).
A data service must be registered or deleted while the logical host is stopped. Sun Cluster can control independently startup and stop of the logical host and startup and stop of data services. Therefore, another service can be added while a service is running in the logical host.
However, if the configuration is changed while a service is running, a problem due to cluster configuration change or a problem caused by the added service, etc., might cause a fail over. Therefore, to ensure stable service operations, do not add a service while another service is running.