Oracle® Solaris 11.2 でのデバイスの管理

印刷ビューの終了

更新: 2014 年 7 月
 
 

テープバックアップ用の RCM スクリプトの例

ここでは、RCM スクリプトを使用したテープバックアップの例を示します。

テープバックアップ用の RCM スクリプトの役割

テープバックアップ用の RCM スクリプトは、次の手順を実行します。

  1. RCM コマンドのディスパッチテーブルを設定します。

  2. 指定した RCM コマンドに対応するディスパッチルーチンを呼び出し、未実装の RCM コマンドのステータス 2 で終了させます。

  3. scriptinfo セクションを設定します。

    rcm_script_func_info=Tape backup appl script for DR
  4. すべてのテープドライブのデバイス名を stdout に印刷して、すべてのテープドライバをシステムに登録します。

    rcm_resource_name=/dev/rmt/$f

    エラーが発生した場合、スクリプトによりエラー情報が stdout に出力されます。

    rcm_failure_reason=$errmsg
  5. テープデバイスのリソース情報を設定します。

    rcm_resource_usage_info=Backup Tape Unit Number $unit
  6. バックアップアプリケーションがそのデバイスを使用しているかどうか確認して、preremove 情報を設定します。バックアップアプリケーションがそのデバイスを使用していない場合、動的再構成操作が続行されます。バックアップアプリケーションがそのデバイスを使用している場合、スクリプトにより RCM_ENV_FORCE が検査されます。RCM_ENV_FORCEFALSE に設定されている場合、スクリプトにより動的再構成操作が拒否され、次のメッセージが印刷されます。

    rcm_failure_reason=tape backup in progress pid=...

    RCM_ENV_FORCETRUE に設定されている場合、バックアップアプリケーションが停止し、再構成操作が続行されます。

テープバックアップ再構成シナリオの結果

    RCM スクリプトを使わずに cfgadm コマンドを使ってテープドライブを取り外した場合、次のような結果になります。

  • バックアップアプリケーションがテープドライブを使用していない場合に cfgadm コマンドを使用すると、操作は正常に実行されます。

  • バックアップアプリケーションがテープドライブを使用中に cfgadm コマンドを使用すると、操作が失敗します。

RCM スクリプトと cfgadm コマンドを使ってテープドライブを取り外した場合、次のような結果になります。

  • バックアップアプリケーションがテープドライブを使用していない場合に cfgadm コマンドを使用すると、操作は正常に実行されます。

  • バックアップアプリケーションがテープドライブを使用しているときに、–f オプションを指定せずに cfgadm コマンドを使用すると、次のようなエラーメッセージが表示され、操作が失敗します。

    tape backup in progress pid=...
  • バックアップアプリケーションがテープドライブを使用しているときに、f オプションを指定して –cfgadm コマンドを使用すると、スクリプトによってバックアップアプリケーションが停止され、cfgadm 操作が正常に実行されます。

例 – テープバックアップ用の RCM スクリプト

#! /usr/bin/perl -w
#
# A sample site customization RCM script.
#
# When RCM_ENV_FORCE is FALSE this script indicates to RCM that it cannot
# release the tape drive when the tape drive is being used for backup.
#
# When RCM_ENV_FORCE is TRUE this script allows DR removing a tape drive
# when the tape drive is being used for backup by killing the tape
# backup application.
#

use strict;

my ($cmd, %dispatch);
$cmd = shift(@ARGV);
# dispatch table for RCM commands
%dispatch = (
"scriptinfo"    =>      \&do_scriptinfo,
"register"      =>      \&do_register,
"resourceinfo"  =>      \&do_resourceinfo,
"queryremove"   =>      \&do_preremove,
"preremove"     =>      \&do_preremove
);


if (defined($dispatch{$cmd})) {
&{$dispatch{$cmd}};
} else {
exit (2);
}

sub do_scriptinfo
{
print "rcm_script_version=1\n";
print "rcm_script_func_info=Tape backup appl script for DR\n";
exit (0);
}

sub do_register
{
my ($dir, $f, $errmsg);

$dir = opendir(RMT, "/dev/rmt");
if (!$dir) {
$errmsg = "Unable to open /dev/rmt directory: $!";
print "rcm_failure_reason=$errmsg\n";
exit (1);
}

while ($f = readdir(RMT)) {
# ignore hidden files and multiple names for the same device
if (($f !~ /^\./) && ($f =~ /^[0-9]+$/)) {
print "rcm_resource_name=/dev/rmt/$f\n";
}

}

closedir(RMT);
exit (0);
}
sub do_resourceinfo
{
my ($rsrc, $unit);

$rsrc = shift(@ARGV);
if ($rsrc =~ /^\/dev\/rmt\/([0-9]+)$/) {
$unit = $1;
print "rcm_resource_usage_info=Backup Tape Unit Number $unit\n";
exit (0);
} else {
print "rcm_failure_reason=Unknown tape device!\n";
exit (1);
}
}

sub do_preremove
{
my ($rsrc);

$rsrc = shift(@ARGV);

# check if backup application is using this resource
#if (the backup application is not running on $rsrc) {
# allow the DR to continue
#        exit (0);
#}
#
# If RCM_ENV_FORCE is FALSE deny the operation.
# If RCM_ENV_FORCE is TRUE kill the backup application in order
# to allow the DR operation to proceed
#
if ($ENV{RCM_ENV_FORCE} eq 'TRUE') {
if ($cmd eq 'preremove') {
# kill the tape backup application
}
exit (0);
} else {
#
# indicate that the tape drive can not be released
# since the device is being used for backup by the
# tape backup application
#
print "rcm_failure_reason=tape backup in progress pid=...\n"
;
exit (3);
}
}