Hitachi

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


6.13.2 Creating a server termination command

A server termination command is used to terminate a program automatically. Creation of a server termination command is optional. You create it when you want to terminate a program automatically for a purpose such as grouped-system switchover.

This subsection explains the timing of calling a server termination command and how to create 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.

Organization of this subsection

(1) Timing of calling a server termination command

A created server termination command is executed by HA Monitor with the superuser permissions.

The server termination command is called before shared resources are disconnected in the following cases:

HA Monitor passes an argument that is determined by the event to the server termination command. The arguments include -e, -w, and -c. You must code processing that corresponds to the arguments as shown below.

Table 6‒10: Arguments for a server termination command and the processing to be coded

Argument

Processing to be coded when the argument is passed

-e

Normal termination of the server

-w

Planned termination when planned hot standby processing is performed on the server

-c

Processing required in order to restart the abnormally terminated server

The following table shows the relationships between server termination command start conditions and the arguments.

Table 6‒11: Server termination command start conditions and the arguments to be passed

Server termination command start condition

Argument to be passed#

When termcmd_at_abort=nouse is specified

When termcmd_at_abort=use is used

The server is to be terminated by the monitor-mode server termination command (monend command).

-e

-e

In the event of a server failure, an active server that has no standby server is to be terminated by the monitor-mode server termination command (monend command).

-e

-c

Hot standby processing is to be performed on the server due to a server failure.

-w

-c

The server hot-standby switchover command (monswap or monswap -g command) is to be executed (as planned hot-standby switchover).

-w

-w

In the event of a failure on an active server that has no standby server, a standby server is to be started and then the server hot-standby switchover command (monswap or monswap -g command) is to be executed (as planned hot-standby switchover).

-w

-c

The active server is to be forcibly terminated and then hot standby processing is to be performed for grouped-system switchover.

-w

-w

In the event of a server failure, an active server that has no standby server is to be forcibly terminated for grouped-system switchover.

-w

-c

In the event of a failure on an active server that has no standby server, a standby server is to be started and then hot standby processing is to be performed for grouped-system switchover.

-w

-c

In the event of a server failure, preprocessing is to be performed prior to restarting the active server.

-c

-c

The server startup processing is to be cancelled due to a server start command error.

--

-c

Legend:

--: The server termination command is not issued.

#

The argument to be passed depends on the value of the termcmd_at_abort operand specified in the HA Monitor environment settings. For details about the termcmd_at_abort operand, see 8.3.1 HA Monitor environment settings (sysdef).

(2) How to create a server termination command

For a server termination command, you specify a script such as a shell that codes program termination processing.

If necessary, specify an operating environment needed to terminate the program within the shell. 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 shell.

The following shows the environment variables that are inherited when the server termination command is executed.

The environment variables specified in the Unit settings file of HA Monitor are inherited in the following cases:
  • The OS is RHEL7 or a later version and the HA Monitor version is 01-65 or later.

  • The OS is RHEL7 or a later version, the HA Monitor version is earlier than 01-65, and HA Monitor automatically started when the system started.

The environment variables of the user who executed the HA Monitor start command (monstart command) are inherited in the following cases:

  • The OS is RHEL7 or a later version, the HA Monitor version is earlier than 01-65, and HA Monitor was started by using monstart command.

  • The OS is RHEL6 and HA Monitor was started by using the monstart command.

The environment variables specified in the startup script /etc/rc.d/init.d/HAmon are inherited in the following cases:

  • The OS is RHEL6 and HA Monitor automatically started when the system started.

To use a server termination command to terminate a UAP that issues APIs when using the monitor-mode program management function, specify the program name in a UAP environment variable. In the server termination command, specify all target UAP termination processes. If a UAP creates processes, also specify the processing to terminate those processes. For details about the UAP environment variables, see 6.16.2 Specifying UAP environment variables.

Specify the created server termination command in the termcommand operand in the server environment definition. You can also use the stop_timeout or stop_timeout_sw operand in the server environment definition to specify the timeout value for the server termination command.

HA Monitor processing is not affected by the return value of a server termination command that is called during normal or planned termination of the active server. When you create a termination command, note the following points:

If you code termination processing for multiple programs in the server termination command, you can use those programs as a server.