Top
PRIMECLUSTER  Installation and Administration Guide4.3

6.6 Setting Up Online/Offline Scripts

Create Online and Offline scripts to start and stop ISV applications and user applications in line with the userApplication state transition.

Set the created scripts as Cmdline resources and set those resources in userApplication.

For details, see "6.7.1.1 Creating Cmdline Resources."

This section presents script examples and describes notes on script creation.

Sample scripts

This section shows samples of the Online and Offline scripts, which are set as Cmdline resources.

Figure 6.1 Start script/Stop script

The above script sample is both for the Start script and Stop script.

An example of Check script is shown below:

Figure 6.2 Check script

Set up the above scripts in the Cmdline resource as shown below:

For information on how to set up these scripts, see "6.7.1.1 Creating Cmdline Resources."

Notes on script creation

Hot-standby operation

To enable hot-standby operation of the Cmdline resources, the following must be prepared:

  1. Create the Online, Offline, and Check scripts to support hot-standby operation. The sample scripts are shown below.

    Figure 6.3 Start script/Stop script (hot-standby operation)

    The following example shows Check script that supports hot-standby operation.

    Figure 6.4 Check script (hot-standby operation)

  2. Setting attributes for the Cmdline resources

    Enable the STANDBYCAPABLE and the ALLEXITCODES attributes.

    For details, see "6.7.1.1 Creating Cmdline Resources."

Online/Offline script exit code

The state transition process of userApplication changes according to the exit code of the Online/Offline script:

0: Normal exit

The system assumes that the state transition of the Cmdline resource was processed normally, and state transition processing of the userApplication continues. If all the resources of the userApplication are processed normally, the state transition of the userApplication is also processed normally.

Other than 0: Abnormal exit

The system assumes that an error occurred during the state transition of the Cmdline resources and interrupts state transition processing of the userApplication.

Check script exit code

The state of the Cmdline resource is determined by the exit code of Check script. The exit code and the Cmdline resource are associated each other as follows:

0: Indicates the Online state.
Other than 0: Indicates the Offline state.

When ALLEXITCODES variables of the Cmdline resources are enabled, Check script will provide more detailed state of the resource. The exit code and Cmdline resource are associated each other as follows:

0: Indicates the Online state.

1: Indicates the Offline state.

2: Indicates the Faulted state.

3: Indicates the Unknown state.

4: Indicates the Standby state.

5: Indicates the Onlinewarning state.

6: Indicates the Offlinefaulted state.

For details, see "HELP."

Timeout

If script processing is not completed within the specified time, a timeout occurs, script processing is interrupted by the SIGTERM signal, and state transition ends with an error.

Default: 300 seconds

The timeout value can be specified with the TIMEOUT flag value of the Cmdline resources.

When creating the Cmdline resource, you need to set up a timeout value in "Setting up Cmdline flags" of "6.7.1.1 Creating Cmdline Resources." If a timeout occurs when a Cmdline resource is used, change the timeout value to an appropriate value according to the instructions in "8.1.3 Changing Resources."

Environment variables

When the script is executed, the environment variables shown in the table below are set.

Environment variable

Outline

HV_APPLICATION

This variable sets the userApplication name that the resource belongs to.

Example) app1

HV_AUTORECOVER

The value of this variable indicates whether the script is triggered by AutoRecover or not (1 or 0). For details on AutoRecover, see "11 Appendix - Attributes" in "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."
0: Not triggered by AutoRecover
1: Triggered by AutoRecover

HV_FORCED_REQUEST

This variable sets a value that indicates whether or not forced failover was requested by operator intervention.

0: Forced failover was not requested.
1: Forced failover was requested.

HV_NODENAME

This variable contains the resource name.

Example) Cmdline0

HV_OFFLINE_REASON

This variable sets the trigger for bringing the resource Offline.

SWITCH: The resource was set to Offline because of a userApplication switchover request (hvswitch).
STOP: The resource was set to Offline because of a userApplication stop request (hvutil -f)
FAULT: The resource was set to Offline because of a resource fault.
DEACT: The resource was set to Offline because of a userApplication deactivate request (hvutil -d)
SHUT: The resource was set to Offline because of an RMS stop request (hvshut)

HV_SCRIPT_TYPE

This variable sets the type of script that was executed.

Online: Online script

Offline: Offline script

HV_LAST_DET_REPORT

This variable sets the state of the current resources.

Online: Online state
Offline: Offline state
Standby: Standby state
Faulted: Faulted state
Warning: Warning state

HV_INTENDED_STATE

This variable sets the resource state that is expected after state transition is completed.

Online: Online state
Offline: Offline state
Standby: Standby state
Faulted: Faulted state
Warning: Warning state

NODE_SCRIPTS_TIME_OUT

This variable sets the timeout duration (seconds) of the script.

Example) 300

When executing the Check script, the following environment variables in the above table are set:

  • HV_APPLICATION

  • HV_NODENAME

RMS also has other environment variables. For information on the other environment variables, see the files below.

File Names

Contents

hvenv

Environment variable file to be defined in the entire cluster system

hvenv.local

Environment variable file to be defined only in that node

See

  • For details on the RMS environment variable files (hvenv and hvenv.local), see "2.9 Environment Variables" in the "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."

  • For details on the RMS environment variables, see "12 Appendix - Environment Variables" in the "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."