Xsan 2.1.1:フェイルオーバー後に Intel ベースの Xserve MDC を再起動するスクリプト

フェイルオーバー後に Intel ベースの Xserve MDC を再起動するスクリプトを紹介します。

この記事に記載されたスクリプトにより、Xsan ボリュームのフェイルオーバーの後、Xsan ボリュームの制御を失った Xsan メタデータコントローラ (MDC) が即座に再起動されます。何らかの理由でフェイルオーバーが起こった場合には、ボリュームの制御を引き継いだ MDC がこのスクリプトを実行します。このスクリプトは、Lights Out Management (LOM) を使って、以前にアクティブであった MDC に再起動信号を送ります。この処理により、以前にアクティブであった MDC によってフェイルオーバー後に Xsan ボリュームのメタデータが変更されないようになります。

Xsan には、複数の MDC で Xsan ボリュームがアクティブになる状況を回避するための複数の予防手段があります。このスクリプトは、必須ではありません。通常発生しないこのような状況を回避するために、ハードウェアベースの方法を追加したい運用に対しての一例として提供しています。

このスクリプトの使用は任意です。お客様の責任においてご利用ください。インストールする前に、システム条件を確認してください。Apple では、このスクリプトの変更についてサポートを提供していません。

  • このスクリプトは、Xsan 2.1.1 を実行する 2 台 の MDC が使用されている Xsan 用に設計されています。3 台以上の MDC によって Xsan ボリュームがホストされている場合には、このスクリプトは実装しないでください。

  • このスクリプトは、再起動信号を送信するために LOM コマンドを使用するので、MDC には 2 台とも Intel ベースの Xserve を使用する必要があります。

  • このスクリプトは、複数のボリュームがある Xsan で使用できます。各ボリュームは、同じフェイルオーバー優先順位が設定された 2 台の MDC で動作するように設定されている必要があります。

  • Xsan MDC 上には、Xsan サービスと Open Directory サービスのみがホストされることを推奨します。MDC で Open Directory サービスが実行されている場合には、常に Open Directory の複製が使用可能になっていることが重要です。これにより、このスクリプトによって MDC が再起動されたとしても、Open Directory サービスの継続的な利用が可能になります。

  • 重要:MDC の内蔵ハードドライブは、Mac OS 拡張 (ジャーナリング) でフォーマットされている必要があります。

スクリプトのインストール

2 台の MDC で下記の手順を実行します。

  1. こちらの記事で説明している手順にそって、LOM のアドレスを設定します。

  2. 以下のコマンドを実行して、LOM のパスワードファイルを作成します。

    sudo sh -c "echo PASSWORD > /private/var/root/Other_MDCs_LOM_Password"

    Replace ‘PASSWORD’ with the LOM administrator’s password on the other MDC.

  3. ターミナルで次のコマンドを実行して、LOM のパスワードファイルへのアクセスを制限します。

    sudo chmod 400 /private/var/root/Other_MDCs_LOM_Password

    sudo chown root:wheel /private/var/root/Other_MDCs_LOM_Password

  4. 次のターミナルコマンドを実行して、元のスクリプトをバックアップします。

    sudo mv /Library/Filesystems/Xsan/bin/cvfail /Library/Filesystems/Xsan/bin/cvfail.bak

  5. 新しいスクリプトを作成するには、以下の「#!/bin/sh” to the “# end script” line. Paste the text into a new plain text document in TextEdit, using these guidelines.

    #!/bin/sh# cvfail# This script is intended for use in Xsan 2.1.1.# This script may be replaced by a future software update.# -------------- edit the variables below this line ----------------# For more information on these settings: http://support.apple.com/kb/HT3620# Set reset_enabled to 'yes' to reset the other MDC upon failover.# Set to 'no' to disable reset on both MDCs before performing maintenance.reset_enabled='no'# IP address of other MDC's Lights Out Management (LOM) interfacelom_ip='Other_MDCs_LOM_IP_address'# LOM admin user on other MDClom_username='Other_MDCs_LOM_admin_username'# LOM password for other MDC is stored in this filelom_password_file='/private/var/root/Other_MDCs_LOM_Password'# name of SANsan_name='My Xsan'# ------------------ do not edit below this line ------------------hostname="$1" fsm_port="$2" fs_name="$3" last_reset='/private/tmp/.cvfail'reset_interval=15sendNotification() { # Note: notification method is subject to change in future versions if [ ! "$subject" ]; then command="xsan:command = sendFailoverxsan:hostname = $hostnamexsan:volume = $fs_name" else command="xsan:command = sendNotificationxsan:messageSubject = $subjectxsan:messageBody = $bodyxsan:messageType = failover" fi echo "$command" | /usr/sbin/serveradmin command &}messageBody() { input=`echo $1 | /usr/bin/tr -d '\n\r' | /usr/bin/sed "s/\"//g; s/\'//g"` if [ "$body" ]; then body="$body $input" else body="$input" fi}# do not reset the other MDC when in maintenance modeif [ "`echo $reset_enabled | /usr/bin/awk '{print tolower}'`" != 'yes' ]; then echo "cvfail $fs_name: Maintenance mode. MDC will not be reset." sendNotification exit 0 fi# do not reset the other MDC if it has already been reset within reset intervalif [ -f "$last_reset" ]; then eval $(/usr/bin/stat -s "$last_reset") time_since_last_reset=$(($(/bin/date +%s) - $st_ctime)) if [ $time_since_last_reset -le $reset_interval ]; then echo "cvfail $fs_name: MDC already reset. Will not reset again." sendNotification exit 0 fifi# check the password fileif [ ! -r "$lom_password_file" ]; then echo "cvfail $fs_name: $lom_password_file: Cannot read file or file does not exist." subject="$san_name: Volume $fs_name did not fail over" messageBody "The failover script for the volume $fs_name in $san_name" messageBody "did not complete successfully on $hostname because" messageBody "the password file ($lom_password_file) could not be read or does not exist." sendNotification exit 1fi# reset the other MDCecho "cvfail $fs_name: Sending reset command as '$lom_username' to LOM IP: $lom_ip" ipmitool_output=`/usr/bin/ipmitool -l lan -U "$lom_username" \ -f "$lom_password_file" -H "$lom_ip" chassis power reset 2>&1`# send the appropriate notificationif [ $? -eq 0 ]; then echo "cvfail $fs_name: MDC reset succeeded." /usr/bin/touch "$last_reset" sendNotification exit 0 else echo "cvfail $fs_name: MDC reset failed. ipmitool: $ipmitool_output" subject="$san_name: Volume $fs_name did not fail over" messageBody "The failover script for the volume $fs_name in $san_name" messageBody "did not complete successfully on $hostname because" messageBody "an ipmitool error occurred: $ipmitool_output" sendNotification exit 1fi# end script

  6. スクリプト内の「edit the variables below this line」が含まれる行から「do not edit below this line」が含まれる行までの変数を編集します。これらの変数は、上記のテキストで黄色にハイライト表示されていますが、標準テキストのスクリプトではハイライトされていない状態で表示されます。ここで入力する値は、もう一方の MDC に関係するものであることに留意してください。各値を囲んでいる一重引用符 (') はそのままにしておきます。

    • reset_enabled='yes'

      Leave this value set to yes on both MDCs during normal operation.

      Important: To prevent the script from rebooting the other MDC during planned maintenance, change this value to no on both MDCs before performing maintenance. Planned maintenance tasks include running Software Update on either MDC, starting a volume, changing volume settings, or forcing failover.

    • san_name='My Xsan'

      Replace My Xsan with the name of the SAN found by selecting Overview from the left-hand column in Xsan Admin and observing the Name value.

  7. 次の場所に新しいスクリプトを保存します。

    /Library/Filesystems/Xsan/bin/cvfail

  8. ターミナルで以下のコマンドを実行します。

    sudo chmod 544 /Library/Filesystems/Xsan/bin/cvfail

    sudo chown root:wheel /Library/Filesystems/Xsan/bin/cvfail

関連情報

スクリプトのテスト

両方の MDC にスクリプトを実装したら、下記の手順でその機能をテストできます。

  1. Xsan Admin を起動して、「SAN アセット」で「ボリューム」を選択します。テスト対象の Xsan ボリュームの「ホストサーバ」の値を確認します。

  2. アクションボタンをクリックし、「強制的にフェイルオーバーを行う」を選択します。

    Note: If you are running Xsan Admin on the MDC that was running the volume, the system will reboot immediately. If you are running Xsan Admin on another Mac, Xsan Admin may become unresponsive after the Force Failover command. If Xsan Admin’s “Failing-over volume” progress dialog does not close after one minute, force Xsan Admin to quit.

  3. 必要に応じて、Xsan Admin で SAN に再接続します。フェイルオーバーさせた Xsan ボリュームの「ホストサーバ」の値を確認します。フェイルオーバーイベントが正常に完了した場合、値はもう一方の MDC の名前になるはずです。

:フェイルオーバーをテストすることによって一時的に Xsan ボリュームを使用できなくなる可能性があります。本稼働ではない時間にフェイルオーバーをテストして、本稼働が中断される事のないようにしてください。

公開日: