ADSM-L

Re: Client and AIX mirrored disks...

2001-10-29 15:37:46
Subject: Re: Client and AIX mirrored disks...
From: Thomas Denier <Thomas.Denier AT MAIL.TJU DOT EDU>
Date: Mon, 29 Oct 2001 15:35:04 -0500
Quoting Robin Sharpe <Robin_Sharpe AT BERLEX DOT COM>:

> I'd love to see that script, if you're willing to share!   :)

I took a look. There is actually a whole complex of scripts, designed
to support the use of the snapshot facility of the HP-UX LVM as well
as broken mirrors.

The top level script is as follows:

#!/bin/ksh
dsm_first_phase=$1
export PATH=/usr/bin:/usr/local/bin
exec >>/var/adm/adsm/$(date +%Y%m%d).log 2>&1
function adsm_alert {
  echo "$2"
  dsmadmc -id=monitor -password=monitor ALERT $dsm_host $2
}
typeset -fx adsm_alert
function adsm_phase_backup {
  typeset exit_code
  dsmc incremental
  exit_code=$?
  if [ "$exit_code" -ne 0 ]; then
    adsm_alert err "ADSM backup ended with exit code $exit_code"
  fi
  return $exit_code
}
function do_phase {
  if [ "$1" = "$dsm_first_phase" ]; then
    dsm_run='yes'
  fi
  if [ -n "$dsm_run" ]; then
    if [ -n "$2" ]; then
      dsmadmc -id=monitor -password=monitor WAIT $dsm_host $2 $3
    fi
    "adsm_phase_$1"
    dsm_exit_code=$?
    if [ -n "$2" ]; then
      dsmadmc -id=monitor -password=monitor ENDWAIT $dsm_host $2 $3
    fi
    if [ "$dsm_exit_code" -ne 0 ]; then
      exit 1
    fi
  fi
}
find /var/adm/adsm -name '*.log' -mtime +7 -exec rm {} \;
if [ -z "$dsm_first_phase" ]; then
  dsm_run='yes'
fi
export dsm_host=$(hostname)
. adsm_phases
if [ -z "$dsm_run" ]; then
  adsm_alert err "Initial phase $dsm_first_phase not recognized"
fi

The various dsmadmc commands are part of a devious scheme for passing
information to the NetView console automation product on the mainframe
that hosts our TSM server. The adsm_phases script is as follows:

do_phase snapshot 600 'snapshot'
do_phase backupom
do_phase unmount 600 'unmounting'

The adsm_phase_snapshot script is as follows:

#!/bin/ksh
# This script will run as a pre-exec script to ADSM.  It will setup snapshot
# file systems for the OpenMail file systems and perform the backup of the
# /home/unison file system to /home/unison/backup with OpenTime staying up.
#
# Created by Unix Support on 01/03/2000.
#

MIRRORFS=/usr/local/etc/adsm_mirror

/opt/openmail/bin/omsuspend -s 299
RC=$?
if [ $RC -ne 0 ]; then
  adsm_alert err "OpenMail suspend failed"
  exit $RC
fi

while read LV FS MLV MFS; do
  /usr/sbin/lvsplit $LV 2>&1
  RC=$?
  if [ $RC -ne 0 ]; then
    adsm_alert err "Split of $LV failed"
    exit $RC
  fi
done < $MIRRORFS

while read LV FS MLV MFS; do
  /usr/sbin/fsck -F vxfs -y $MLV 2>&1
  RC=$?
  if [ $RC -ne 0 ]; then
    adsm_alert err "Check of $MLV failed"
    exit $RC
  fi
done < $MIRRORFS

while read LV FS MLV MFS; do
  /usr/sbin/mount -F vxfs $MLV $MFS 2>&1
  RC=$?
  if [ $RC -ne 0 ]; then
    adsm_alert err "Mount of $MFS failed"
    exit $RC
  fi
done < $MIRRORFS

while read SNAPDEV SNAPMP REALMP; do
  /usr/sbin/mount -F vxfs -o snapof=$REALMP $SNAPDEV $SNAPMP
  RC=$?
  if [ $RC -ne 0 ]; then
    adsm_alert err "Mount of $SNAPMP failed"
    exit $RC
  fi
done </usr/local/etc/adsm_snapshot
/opt/openmail/bin/omsuspend -r
RC=$?
if [ $RC -ne 0 ]; then
  adsm_alert err "OpenMail resume failed"
  exit $RC
fi

/home/unison/bin/unidbbackup -d /home/unison/backup 2>&1

The adsm_phase_backupom script is as follows:

#!/usr/bin/perl

use strict;

sub alert;

my %excluded;
open SNAPSHOTS, '/usr/local/etc/adsm_snapshot' or alert 'Open failed';
my @snapshots = <SNAPSHOTS>;
foreach (@snapshots) {
  my ($device, $snapshot, $original) = split;
  $excluded{$original} = 1;
}
open MIRRORS, '/usr/local/etc/adsm_mirror' or alert 'Open failed';
my @mirrors = <MIRRORS>;
foreach (@mirrors) {
  my ($device, $fs, $mirrordevice, $mirrorfs) = split;
  $excluded{$fs} = 1;
}
open FSLIST, 'df -n|' or alert 'df failed';
my @filesystems = <FSLIST>;
my @domain;
foreach (@filesystems) {
  chomp;
  my ($name, $type) = /^(\S*)\s[^:]*:\s*(.*)/;
  next if $name eq '/tmp';
  next if $type eq 'cdfs';
  next if exists $excluded{$name};
  push @domain, $name;
}
unshift @domain, 'dsmc', 'incremental';
my $outcome = system @domain;
if ($outcome > 0x80) {
  my $status = $outcome>>8;
  alert "dsmc ended with rc $status"
}
if ($outcome != 0) {
  die "dsmc ended by signal $outcome"
}

sub alert {
  my ($message) = @_;
  system 'adsm_alert', 'err', $message;
  exit 1;
}

The adsm_phase_unmount script is as follows:

#!/bin/ksh
# This script will run as a post-exec script to ADSM.  It will unmount the
# snapshot file systems for the OpenMail file systems.
#
# Created by Unix Support on 01/03/2000.
#
while read SNAPDEV SNAPMP REALMP; do
  for iteration in 1 2 3 4 5 6; do
    /usr/sbin/umount $SNAPMP
    RC=$?
    if [ $RC -eq 0 ]; then
      break
    fi
    sleep 30
  done
  if [ $RC -ne 0 ]; then
    adsm_alert err "Unmount of $SNAPMP failed"
    exit $RC
  fi
done </usr/local/etc/adsm_snapshot

# Give ADSM time to release Mirrored File Systems
sleep 120

MIRRORFS=/usr/local/etc/adsm_mirror

while read LV FS MLV MFS; do
  /usr/sbin/umount $MFS 2>&1
  RC=$?
  if [ $RC -ne 0 ]; then
    adsm_alert err "Unmount of $MFS failed"
    exit $RC
  fi
done < $MIRRORFS

while read LV FS MLV MFS; do
  /usr/sbin/lvmerge $MLV $LV 2>&1
  RC=$?
  if [ $RC -ne 0 ]; then
    adsm_alert err "Merge of $MLV failed"
    exit $RC
  fi
done < $MIRRORFS

The adsm_alert script is as follows:

#!/usr/bin/ksh
echo "$2"
HOST=`/usr/bin/hostname`
/usr/bin/dsmadmc -id=monitor -password=monitor ALERT $HOST $2
exit 0

As before, the dsmadmc command is used to pass information to NetView.
The adsm_mirror file read by some of the scripts is as follows:

/dev/vg03/lvol1 /var/opt/openmail /dev/vg03/lvol1b /var/opt/openmailM

The adsm_snapshot file read by some of the scripts is as follows:

/dev/vg03/lvol9 /var/opt/openmail/dataS /var/opt/openmail/data
<Prev in Thread] Current Thread [Next in Thread>