![]() |
![]() |
The following examples of scripts demonstrate how to start and stop HSM in an HACMP environment on an AIX file system. These scripts are only examples. You must create your own scripts for your environment.
Figure 2. start_HSM : A Sample Script That Starts the HSM and Imports all File Systems
+--------------------------------------------------------------------------------+ |#! /usr/bin/perl | |#------------------------------------------------------------------ | |# call with | |# start_HSM [filesystems] | |#------------------------------------------------------------------ | | | |my $LOG="/tmp/HSM.log"; # place of your logfile | | | |$ENV{"DSM_DIR"}="[your location of dsm.sys]"; | |$ENV{"DSM_CONFIG"}="[your location of option file]"; | |`echo "***************************************************" >> $LOG`; | |`echo "* Starting HSM *" >> $LOG`; | |`echo "***************************************************" >> $LOG`; | | | |`echo START \\\\t\\\\t \`date\` >> $LOG`; | |`echo \$DSM_DIR \$DSM_CONFIG >> $LOG`; | | | |# killing all running demons to reread the option files | |`echo "Killing dsmrecalld ..." >> $LOG`; | |`kill -15 \$(ps -aef|grep dsmrecalld |grep -v grep |awk '{print \$2}') | |2>&1 1>> $LOG`; | |`echo "Killing dsmmonitord ..." >> $LOG`; | |`kill -15 \$(ps -aef|grep dsmmonitord |grep -v grep |awk '{print \$2}') | |2>&1 1>> $LOG`; | |`echo "Killing dsmscoutd ..." >> $LOG`; | |`kill -15 \$(ps -aef|grep dsmscoutd |grep -v grep |awk '{print \$2}') | |2>&1 1>> $LOG`; | | | |# starting the demons with the right dsm.sys and dsm.opt | |`echo "Starting dsmmonitord ..." >> $LOG`; | |`echo \$DSM_DIR \$DSM_CONFIG >> $LOG; | |dsmmonitord 2>&1 1>> $LOG`; | |`echo "Starting dsmrecalld ..." >> $LOG`; | |`echo \$DSM_DIR \$DSM_CONFIG >> $LOG; dsmrecalld 2>&1 1>> $LOG`; | |`echo "Starting dsmscoutd ..." >> $LOG`; | |`echo \$DSM_DIR \$DSM_CONFIG >> $LOG; dsmscoutd 2>&1 1>> $LOG`; | | | |# transfer the command line into an array | |while(my $temp=shift @ARGV){ | | $FS[@FS]=$temp; | |} | | | |# import all filesystems | |`echo "Starting to import FS.." >> $LOG`; | |for(my $i=0; $i < @FS; $i++){ | | `dsmmigfs import $FS[$i] 2>&1 1>> $LOG`; | |} | | | |`echo "HSM is Started" >> $LOG`; | +--------------------------------------------------------------------------------+
Figure 3. stop_HSM : Stops HSM and Exports All Filesystems
+--------------------------------------------------------------------------------+ |#! /usr/bin/perl | |#------------------------------------------------------------------ # | |call with | |# stop_HSM [filesystems] | |#------------------------------------------------------------------ | |my $LOG="/tmp/HSM.log"; # place of your logfile | | | |$ENV{"DSM_DIR"}="[your location of dsm.sys]"; | |$ENV{"DSM_CONFIG"}="[your location of option file]"; | |`echo "***************************************************" >> $LOG`; | |`echo "* Stoping HSM *" >> $LOG`; | |`echo "***************************************************" >> $LOG`; | | | |`echo STOP\\\\t\\\\t \`date\` >> $LOG`; | |`echo \$DSM_DIR \$DSM_CONFIG >> $LOG`; | | | |# before you can export the filesystems, you have to stop all demons | |`echo "Killing dsmrecalld ..." >> $LOG`; | |`kill -15 \$(ps -aef|grep dsmrecalld |grep -v grep |awk '{print \$2}') | |2>&1 1>> $LOG`; | |`echo "Killing dsmmonitord ..." >> $LOG`; | |`kill -15 \$(ps -aef|grep dsmmonitord |grep -v grep |awk '{print \$2}') | |2>&1 1>> $LOG`; | |`echo "Killing dsmscoutd ..." >> $LOG`; | |`kill -15 \$(ps -aef|grep dsmscoutd |grep -v grep |awk '{print \$2}') | |2>&1 1>> $LOG`; | | | |# transfer the command line into an array | |while(my $temp=shift @ARGV){ | | $FS[@FS]=$temp; | |} | | | |# to export the filesystems, you have to stop all processes using this filesyste| |`echo "Killing the rest ..." >> $LOG`; | |for(my $i=0; $i < @FS; $i++){ | | @PROCS=split (" ",`fuser -c $FS[$i] 2>/dev/null`); | | while(my $PROC=shift @PROCS){ | | $PROC=~s/c//g; | | `kill -9 $PROC 2>&1 1>> $LOG`; | | } | |} | | | |# now you can export the filesystems | |`echo "Starting to export FS.." >> $LOG`; | |for(my $i=0; $i < @FS; $i++){ | | `dsmmigfs export $FS[$i] 2>&1 1>> $LOG`; | | } | |`echo "HSM is stopped" >> $LOG`; | +--------------------------------------------------------------------------------+