ユーザがあらかじめ用意したコマンドを特定のタイミングで実行することができます。実行タイミングの詳細は、“2.8.2 ユーザコマンド実行機能”を参照してください。本機能によりNIC切替方式運用の場合には、ARPテーブルのフラッシュ、インタフェース状態の変更、MTU長の変更等の処理を実行させることができます。実行させるためには、以下の設定を行う必要があります。なお、サンプルファイルが用意されていますので、ユーザ環境に適したスクリプトファイルを作成する場合の参考にしてください。
/etc/opt/FJSVhanet/script/interface/sha.interface.sam(IPアドレス活性、非活性時)
/etc/opt/FJSVhanet/script/failover/sha.failover.sam(伝送路異常検出時)
/etc/opt/FJSVhanet/script/patrol/sha.patrol.sam(待機パトロール異常、復旧検出時)
/etc/opt/FJSVhanet/script/alive/sha.alive.sam(仮想インタフェース異常、復旧検出時)
/etc/opt/FJSVhanet/script/host/node_event.sam
/etc/opt/FJSVhanet/script/interface/sha-NN.takeover.interface.sam(引継ぎ仮想インタフェース活性、非活性時)
/etc/opt/FJSVhanet/script/system/monitor.sam
設定ファイルの配置先およびファイル名は仮想インタフェースの種別および仮想インタフェース名ごとに異なります。
/etc/opt/FJSVhanet/script/interface/shaX(IPアドレス活性、非活性時)
/etc/opt/FJSVhanet/script/failover/shaX(伝送路異常検出時)
/etc/opt/FJSVhanet/script/patrol/shaX(待機パトロール異常、復旧検出時)
※shaXは作成したNIC切替方式の仮想インタフェース名。
/etc/opt/FJSVhanet/script/alive/shaX(仮想インタフェース異常、復旧検出時)
※shaXは作成した仮想NIC方式の仮想インタフェース名。
/etc/opt/FJSVhanet/script/host/node_event
/etc/opt/FJSVhanet/script/interface/shaX-NN(引継ぎ仮想インタフェース活性、非活性時)
※shaX-NNは引継ぎ仮想インタフェース名(shaX:NN)のコロン(:)をハイフン(-)に変換した名前。
/etc/opt/FJSVhanet/script/system/monitor
注意
スクリプトファイル内では、伝送路二重化機能の以下のコマンドは呼び出さないでください。
hanetconfig
strhanet
stphanet
hanetpoll
hanetnic
hanetpathmon
hanetobserv
dspobserv
resethanet
スクリプトファイル内でクラスタリソースを操作するコマンドを実行する場合は、必ずバックグランドで実行してください(コマンドの後に“&”を付けて実行)。また、バックグランドで実行されたコマンドの完了は、“wait”などで待ち合わせしないようにしてください。
ユーザコマンドの実行を設定した場合、GLSはシェルスクリプトの完了を待ち合わせます。シェルスクリプト内に時間がかかる処理を記載した場合、その後の処理が遅延する可能性があります。シェルスクリプト内には、時間がかかる処理をバックグランドで実行させて、シェルスクリプトが即時に完了できるように記載してください。
スクリプトファイル内で実行されるコマンドの出力メッセージは、標準出力には表示されません。出力メッセージの内容を確認したい場合は、OSのloggerコマンド等を使用して、メッセージを出力してください。
クラスタ構成の場合、IPアドレス活性、非活性時に実行されるNIC切替方式用のスクリプトは、運用ノードでのみ実行されます。待機ノードでは実行されません。
スクリプトファイルは、仮想インタフェースごとに作成します。このため、1つの仮想インタフェースに、IPv4アドレスとIPv6アドレスの両方が設定されている場合(デュアルスタック構成の場合)は、スクリプトファイル内でアドレスファミリごとに処理を分けて記述してください。
セルフチェック機能のスクリプトを使用してGLSの制御デーモンを自動的に再起動させることはできません。システムをリブートして制御デーモンを復旧させてください。
SELinuxを有効にした環境において、ユーザスクリプト内で独自のポリシーを持つコマンドを実行した場合、システムログに、GLSの内部ログ(/var/opt/FJSVhanet/log/sh.log)に対するアクセス違反が記録されることがあります。スクリプトの動作に影響がある場合、SELinuxのモジュールでアクセス権の例外を定義して回避してください。詳細は、OSのマニュアルを参照してください。
参考
GLSはスクリプトファイルの終了コードを参照していないため、終了コードによってGLSの機能が影響を受けることはありません。
スクリプトファイル呼出形式および定義ファイルサンプルを以下に示します。
(1) IPアドレス活性、非活性時
/bin/sh shaX param1 param2 param3 param4
activate:活性
inactivate:非活性
before:活性/非活性の前
after:活性/非活性の後
ifname:物理インタフェース名
inet6:アドレスファミリ(IPv6の場合のみ)
※IPv4の場合 param4 はありません。
【定義ファイルサンプル】
#!/bin/sh
#
# All Rights Reserved, Copyright (c) FUJITSU LIMITED 2004
#
#ident "%W% %G% %U% - FUJITSU"
#
#
# Control interface for HA-Net
#
#
# Params
#
# $1 activate or inactivate
# $2 before or after
# $3 physical interface name
# $4 address family (IPv6 only)
#
#
# Set Params
#
#INTERFACE=$3
#IP_ADDR1="xx.xx.xx.xx"
#IP_ADDR2="yy.yy.yy.yy"
case $# in
3)
ADDRESS_FAMILY="inet"
;;
4)
if [ $4 = "inet6" ]
then
ADDRESS_FAMILY="inet6"
else
ADDRESS_FAMILY="unknown"
fi
;;
*)
ADDRESS_FAMILY="unknown"
;;
esac
if [ $ADDRESS_FAMILY = "inet" ]
then
case "$1" in
'activate')
#
# Activate interface
#
case "$2" in
'before')
#
# script before activate interface
#
# echo "execute script before activate interface on" $INTERFACE > /dev/console
#if [ ! $INTERFACE = "ethX" ]
#then
# ifconfig $INTERFACE
#else
# ifconfig $INTERFACE
#fi
;;
'after')
#
# script after activate interface
#
# echo "execute script after activate interface on" $INTERFACE > /dev/console
#if [ ! $INTERFACE = "ethX" ]
#then
# arp -d $IP_ADDR1
# ping $IP_ADDR2 2
#else
# arp -d $IP_ADDR2
# ping $IP_ADDR1 2
#fi
;;
*)
;;
esac
;;
'inactivate')
#
# inactivate interface
#
case "$2" in
'before')
#
# script before inactivate interface
#
# echo "execute script before inactivate interface on" $INTERFACE >/dev/console
;;
'after')
#
# script after inactivate interface
#
# echo "execute script after inactivate interface on" $INTERFACE > /dev/console
;;
*)
;;
esac
;;
*)
;;
esac
fi
if [ $ADDRESS_FAMILY = "inet6" ]
then
case "$1" in
'activate')
#
# Activate interface
#
case "$2" in
'before')
#
# script before activate interface
#
# echo "execute script before activate interface on" $INTERFACE > /dev/console
;;
'after')
#
# script after activate interface
#
# echo "execute script after activate interface on" $INTERFACE > /dev/console
;;
*)
;;
esac
;;
'inactivate')
#
# inactivate interface
#
case "$2" in
'before')
#
# script before inactivate interface
#
# echo "execute script before inactivate interface on" $INTERFACE >/dev/console
;;
'after')
#
# script after inactivate interface
#
# echo "execute script after inactivate interface on" $INTERFACE > /dev/console
;;
*)
;;
esac
;;
*)
;;
esac
fi
exit 0 |
(2) 伝送路異常検出時
/bin/sh shaX param1 param2
Primary:プライマリインタフェース異常
Secondary:セカンダリインタフェース異常
all:プライマリ/セカンダリインタフェース双方異常
retryout:pingコマンドのリトライアウト
linkdown:インタフェースがリンクダウン
pinghang:pingコマンドのハングアップ
【定義ファイルサンプル】
#!/bin/sh # # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2015 # #ident "%W% %G% %U% - FUJITSU" # # Control interface for HA-Net # # # Params # # $1 communication line state primary/secondary/all # $2 event exit code retryout/linkdown/pinghang # # # Set Params # #STATE=$1 #EXIT_CODE=$2 #PROC="process_name" #kill -15 `/bin/ps -e | /bin/sed -n \ # -e'/'$PROC'$/s/[^0-9 \t].*//p' \ # ` > /dev/null 2>/dev/null #if [ $STATE = "primary" ] #then # if [ $EXIT_CODE = "retryout" ] # then # echo "execute script Polling failover : primary retryout" > /dev/console # elif [ $EXIT_CODE = "linkdown" ] # then # echo "execute script Polling failover : primary linkdown" > /dev/console # elif [ $EXIT_CODE = "pinghang" ] # then # echo "execute script Polling failover : primary pinghang" > /dev/console # fi #fi #if [ $STATE = "secondary" ] #then # if [ $EXIT_CODE = "retryout" ] # then # echo "execute script Polling failover : secondary retryout" > /dev/console # elif [ $EXIT_CODE = "linkdown" ] # then # echo "execute script Polling failover : secondary linkdown" > /dev/console # elif [ $EXIT_CODE = "pinghang" ] # then # echo "execute script Polling failover : secondary pinghang" > /dev/console # fi #fi #if [ $STATE = "all" ] #then # if [ $EXIT_CODE = "retryout" ] # then # echo "execute script Polling failover : all retryout" > /dev/console # elif [ $EXIT_CODE = "linkdown" ] # then # echo "execute script Polling failover : all linkdown" > /dev/console # elif [ $EXIT_CODE = "pinghang" ] # then # echo "execute script Polling failover : all pinghang" > /dev/console # fi #fi |
(3) 待機パトロール異常、復旧検出時
/bin/sh shaX param1 param2
establish:待機パトロール確立
recover:待機NIC監視復旧
fail:待機NIC異常
待機NICの物理インタフェース名:ethX等の物理インタフェース名
unknown:待機NICが未決定の場合
【定義ファイルサンプル】
#!/bin/sh # # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2004 # #ident "%W% %G% %U% - FUJITSU" # # Control interface for HA-Net # # # Params # # $1 standby NIC state establish/recovery/fail # $2 standby NIC name ethX # # # Set Params # #STATE=$1 #NIC=$2 #if [ $STATE = "fail" ] #then # echo "execute script Patrol fail ($NIC)" > /dev/console #fi #if [ $STATE = "establish" ] #then # echo "execute script Patrol establish ($NIC)" > /dev/console #fi #if [ $STATE = "recover" ] #then # echo "execute script Patrol recover ($NIC)" > /dev/console #fi |
スクリプトファイル呼出形式および定義ファイルサンプルを以下に示します。
(1) 仮想インタフェース異常、復旧検出時
/bin/sh shaX param1
failed:仮想インタフェース異常
recover:仮想インタフェース復旧
【定義ファイルサンプル】
#!/bin/sh # # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2016 # # # Control interface for HA-Net # # # Param # # $1 failed or recover # # # Set Params # STATE=$1 VIF=`basename $0` case "$STATE" in 'failed') # # script communication alive state transition to 'failed' # #echo "execute script communication alive state transition. if:$VIF state:$STATE" > /dev/console ;; 'recover') # # script communication alive state transition to 'recover' # #echo "execute script communication alive state transition. if:$VIF state:$STATE" > /dev/console ;; *) exit 1 ;; esac exit 0 |
スクリプトファイル呼出形式および定義ファイルサンプルを以下に示します。
(1) 相手システムのホットスタンバイ切替え、通信相手ホスト監視異常検出、自システムノード切替え時
/bin/sh node_event
【定義ファイルサンプル】
#!/bin/sh
#
# All Rights Reserved, Copyright (c) FUJITSU LIMITED 2005
#
#ident "%W% %G% %U% - FUJITSU"
#
#
# Control interface for HA-Net
#
#
# Params
#
# $1 local ip address
# $2 remote ip address
# $3 event(NODE_DOWN, POLLING_TIMEOUT, or RESOURCE_OFFLINE)
#
case $# in
3)
LOCAL_ADDR=$1
REMOTE_ADDR=$2
EVENT=$3
;;
*)
;;
esac
case $EVENT in
'NODE_DOWN')
#
# NODE_DOWN invokes, when failover occurs at remote host.
#
# execution format) node_event 0.0.0.0 remote ip address NODE_DOWN
;;
'POLLING_TIMEOUT')
#
# POLLING_TIMEOUT invokes, when the route to all virtual IP addresses
# of remote host failed to hold communication for 3 minutes.
#
# execution format) node_event 0.0.0.0 remote ip address POLLING_TIMEOUT
;;
'RESOURCE_OFFLINE')
#
# RESOURCE_OFFLINE invokes, when a virtual interface changes
# its state to inactive over a cluster system.
#
# execution format) node_event local ip address 0.0.0.0 RESOURCE_OFFLINE
;;
*)
;;
esac
exit 0 |
参考
通信相手ホストの監視異常を検出してから、ユーザコマンド実行までの時間を設定することができます。ユーザコマンドは、ユーザスクリプト“node_event”にPOLLING_TIMEOUT オプションを付けて実行します。
デフォルトは、180秒(約3分)です。設定値は、0~7200の範囲で指定します。0を指定時は、ユーザスクリプトを実行しません。
なお、実行までの時間は5秒単位のタイマで管理されているため、設定値と実際に実行される時間を比較すると、最大5秒の幅があります。
以下に設定例を示します。
GLSの内部パラメタを変更します。
ctld.paramに記載されている“observ_polling_timeout”の値を、デフォルト値(180)から最短値(1)に変更します。
/etc/opt/FJSVhanet/config/ctld.param
#
# HA-Net Configuration File
#
# Each entry is of the form:
#
# <param> <value>
#
observ_msg 0
observ_polling_timeout 1 ←変更
max_node_num 4 |
GLSを再起動します。
システムのリブート、またはresethanet -sコマンドでGLSデーモンを再起動して、変更した設定を反映させます。
スクリプトファイル呼出形式および定義ファイルサンプルを以下に示します。
(1) 引継ぎ仮想インタフェース活性、非活性時
/bin/sh shaX-NN param1 param2 param3
active:活性
inactive:非活性
before:活性/非活性の前
after:活性/非活性の後
notice:活性/非活性の事前通知 (beforeの場合のみ)
success:活性/非活性が成功 (afterの場合のみ)
failed:活性/非活性が失敗 (afterの場合のみ)
【定義ファイルサンプル】
#!/bin/sh
#
# All Rights Reserved, Copyright (c) FUJITSU LIMITED 2016
#
#
# Control interface for HA-Net
#
#
# Params
#
# $1 active or inactive
# $2 before or after
# $3 notice or success or failed
#
#
# Set Params
#
EVENT=$1
TIMING=$2
RESULT=$3
VIF=`basename $0`
case "$EVENT" in
'active')
#
# Activate interface
#
case "$TIMING" in
'before')
#
# script before activate interface
#
#echo "execute script before activate interface on $VIF" > /dev/console
;;
'after')
#
# script after activate interface
#
#if [ "$RESULT" = "success" ]; then
# echo "execute script after activate interface on $VIF result:$RESULT" > /dev/console
#else
# echo "execute script after activate interface on $VIF result:$RESULT" > /dev/console
#fi
;;
esac
;;
'inactive')
#
# Inactivate interface
#
case "$TIMING" in
'before')
#
# script before inactivate interface
#
#echo "execute script before inactivate interface on $VIF" > /dev/console
;;
'after')
#
# script after inactivate interface
#
#if [ "$RESULT" = "success" ]; then
# echo "execute script after inactivate interface on $VIF result:$RESULT" > /dev/console
#else
# echo "execute script after inactivate interface on $VIF result:$RESULT" > /dev/console
#fi
;;
esac
;;
*)
exit 1
;;
esac
exit 0 |
スクリプトファイル呼出形式および定義ファイルサンプルを以下に示します。
(1) GLSの異常、復旧検出時
/bin/sh monitor param1 param2
driver:仮想ドライバ
daemon:制御デーモン
hungup:仮想ドライバまたは制御デーモンのハングアップを検出
error:仮想ドライバまたは制御デーモンの異常を検出
process:制御デーモンの異常停止を検出
【定義ファイルサンプル】
#!/bin/sh
#
# All Rights Reserved, Copyright (c) FUJITSU LIMITED 2007
#
#ident "%W% %G% %U% - FUJITSU"
#
#
# Control interface for HA-Net
#
#
# Params
#
# $1 driver ... sha driver
# daemon ... hanetctld
# $2 hungup ... hanetctld or driver hungup has been detected.
# error ... hanetctld or driver i/o error has been detected.
# process ... hanetctld process does not exist.
#
COMPO=$1
ERRKIND=$2
case $COMPO
in
driver)
#
# script when a driver error is detected.
#
;;
daemon)
#
# script when a daemon error is detected.
#
;;
esac
exit 0 |