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.3.1 Setting Up Cmdline Resources."
An Online script is started when userApplication is switched to Online.
An Offline script is started when userApplication is switched to Offline.
A Check script is used to monitor the state of the resource that is started or stopped with an Online or Offline script.
This section presents script examples and describes notes on script creation.
Note
Environment variables set in each server ("/etc/profile" or "etc/bashrc", for example) are not guaranteed to be inherited by Online, Offline, and Check scripts. Therefore, make sure to define the environment variables used with these scripts in each script.
This section shows samples of the Online and Offline scripts, which are set as Cmdline resources.
Start script/Stop script
#!/bin/sh # # Script.sample # Sample of Online/Offline Script # # Copyright(c) 2003 FUJITSU LIMITED. # All rights reserved. # # $1 -c : OnlineScript # -u : OfflineScript if [[ $1 = "-c" ]]; then # Start your application elif [[ $1 = "-u" ]]; then # Stop your application else # Default operation exit 1 # Error fi exit 0
The above script sample covers both the Start script and the Stop script.
An example of Check script is shown below:
Check script
#!/bin/sh # # Script.sample.check # Sample of Check script # # Copyright(c) 2003 FUJITSU LIMITED. # All rights reserved. # # Check the current state of target resource. # If status is Online: exit 0 # If status is not Online: exit 1
Set up the above scripts in the Cmdline resource as shown below:
Start script $FULL_PATH/Script.sample -c
Stop script $FULL_PATH/Script.sample -u
Check script $FULL_PATH/Script.sample.check
For information on how to set up these scripts, see "6.7.3.1 Setting Up Cmdline Resources."
Hot-standby operation
To enable hot-standby operation of the Cmdline resources, the following must be prepared:
Online/Offline/Check scripts that support hot-standby operation.
The setting of attributes for the Cmdline resources
Create the Online, Offline, and Check scripts to support hot-standby operation. The sample scripts are shown below.
Start script/Stop script (hot-standby operation)
#!/bin/sh # # Script.sample # Sample of Online/Offline Script # # Copyright(c) 2003 FUJITSU LIMITED. # All rights reserved. # # $1 -c : OnlineScript # -u : OfflineScript if [[ $1 = "-c" ]]; then if [ ${HV_LAST_DET_REPORT} = "Offline" ]; then if [ ${HV_INTENDED_STATE} = "Standby" ]; then # commands for Offline -> Standby else # commands for Offline -> Online fi else # commands for Standby -> Online fi elif [[ $1 = "-u" ]]; then if [ ${HV_LAST_DET_REPORT} = "Standby" ]; then # commands for Standby -> Offline else # commands for Online -> Offline fi else # Default operation exit 1 # Error fi exit 0
The following example shows Check script that supports hot-standby operation.
Check script (hot-standby operation)
#!/bin/sh # # Script.sample.check # Sample of Check script # # Copyright(c) 2003 FUJITSU LIMITED. # All rights reserved. # # Check the current state of target resource. # If status is Online: exit 0 # If status is Standby: exit 4 # If status is Faulted: exit 2 # If status is Offline: exit 1
Setting attributes for the Cmdline resources
Enable the STANDBYCAPABLE and the ALLEXITCODES attributes.
For details, see "6.7.3.1 Setting Up Cmdline Resources."
Online/Offline script exit code
The state transition process of userApplication changes according to the exit code of the Online/Offline script:
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.
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:
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:
* The exit codes 3, 5, 6 indicate the special status. Use these codes only when the instructions from PRIMECLUSTER products are received. Do not use any exit codes other than the described above.
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 "Change the attribute" of "6.7.3.1 Setting Up 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 "10.3 Changing a Cluster Application."
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 "Appendix D Attributes" in "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide." |
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. |
HV_NODENAME | This variable contains the resource name. Example) ManageProgram000_Cmd_APP1, RunScriptsAlways000_Cmd_APP1 |
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). |
HV_SCRIPT_TYPE | This variable sets the type of script that was executed. Online: Online script |
HV_LAST_DET_REPORT | This variable sets the state of the current resources. Online: Online state |
HV_INTENDED_STATE | This variable sets the resource state that is expected after state transition is completed. Online: Online state |
NODE_SCRIPTS_TIME_OUT | This variable sets the timeout duration (seconds) of the script. Example: 300 |
RMS also has other environment variables.
See
For details on hvenv.local, see "1.9 Environment variables" in "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."
For details on the RMS environment variables, see "Appendix E Environment variables" in "PRIMECLUSTER Reliant Monitor Services (RMS) with Wizard Tools Configuration and Administration Guide."