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 명령을 사용하고 백업 응용 프로그램에서 테이프 장치를 사용하고 있지 않는 경우에는 작업이 성공합니다.

  • cfgadm 명령을 –f 옵션 없이 사용하고 백업 응용 프로그램에서 테이프 장치를 사용하고 있는 경우에는 작업이 실패하고 다음과 비슷한 오류 메시지가 표시됩니다.

    tape backup in progress pid=...
  • cfgadm –f 명령을 사용하고 백업 응용 프로그램에서 테이프 장치를 사용하고 있는 경우에는 스크립트가 백업 응용 프로그램을 중지하고 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);
}
}