Hitachi

For Linux(R) (x86) Systems HA Monitor Cluster Software


6.19.5 How to create user commands

This subsection explains how to create user commands. You must specify a created user command in the usrcommand command in the HA Monitor environment settings.

You create one user command per host. You use a programming language, such as C language or shell language, to create user commands.

When a user command is issued, HA Monitor passes to the user command arguments that provide HA Monitor information and information about the server whose status has changed. The user can code desired processing for all types of status changes in a single file by using the arguments passed from HA Monitor to determine the status change on the server or on HA Monitor.

Specify the necessary operating environment in the user command. In RHEL7 or a later version, you can specify environment variables in the Unit settings file. However, the Unit settings file is overwritten when an overwrite installation of HA Monitor is performed. Therefore, we recommend that you specify an operating environment (environment variables) within the user command.

For details about the environment variables that are inherited when the user command is executed, see (2) How to create a server termination command in 6.13.2 Creating a server termination command. For details about the operating environment of commands that are executed from HA Monitor, see 6.22 Operating environment of commands that are executed from HA Monitor.

Note the following about issuing a user command when the server status has changed:

The server type and server alias name are passed as arguments from HA Monitor when a user command is executed. For details about the arguments that are passed from HA Monitor, see 6.19.3 User command issuance format: when the server status has changed.

Important

Because a user command is issued within HA Monitor processing, if looping occurs within the user command, HA Monitor processing cannot be guaranteed. You must create user commands carefully so that looping will not occur. If looping does occur in a user command, the server might remain indefinitely under start or termination processing.

Commands that can be specified in user commands:
  • You can execute HA Monitor commands from within a user command.

    Note that HA Monitor commands cannot be executed from within a user command that is issued while HA Monitor is starting or terminating (-m start or -m end).

  • There is a command for inheriting information between active and standby servers.

    If you use the command for specifying and displaying server inheritance information (moninfo command), you can inherit any information from the active server to a standby server. This command also enables you to view the information to be inherited.

For details about these commands, see 9. Commands.

Checking a user command's return value:

HA Monitor does not check a user command's execution results. User command execution results have no effect on the HA Monitor processing.

However, there is a function for checking user command execution results and then canceling server startup processing or hot standby processing. For a user command executed at the start of server startup (-s start) or hot-standby switchover (-w start, -a start, or -h start), you can enable the function by specifying the uoc_neck operand in the server environment definition. In this case, if the execution result (termination code) of the user command is not 0, the server startup or hot-standby switchover is canceled.

Synchronizing or not synchronizing HA Monitor processing with user command processing:

HA Monitor processing is performed synchronously with user command processing. However, termination of HA Monitor processing is not synchronized with termination of a user command in the following cases:

  • Termination of active server startup processing (-k online -s end)

  • Termination of hot standby processing that was performed due to a failure at the active server (-k standby -a end)

  • Termination of hot standby processing that was performed due to planned hot standby processing (-k standby -w end)

  • Termination of hot standby processing that was performed due to a host failure (-h end)

  • If HA Monitor is to wait for the active server to be restarted after a failure at the active server (-r)

  • If the restart limit is detected in the event of a failure at the active server (-n)

  • A start retry limit error was detected during hot standby processing (-t)

Creating user commands that control shared resources:

Note the following about creating user commands for controlling shared resources:

  • Connect the shared resources before the active server is started.

    Shared resources must be connected before the active server is started so that the active server can use the shared resources.

  • Disconnect a resource that needs locking between hosts after the active server has terminated.

    The resource must be disconnected after the active server has terminated in order to prevent the resource from being connected from both hosts at the same time.

  • Inherit information about shared resources from the active server to the standby server, if necessary.

    To inherit information about shared resources from the active server to the standby server, you can use the command for specifying and displaying server inheritance information (moninfo command).