128 Highly Available WebSphere Business Integration Solutions
WebSphere MQ scripts
hacrtmqm
This script is used for creating a queue manager for use in an HA environment.
#!/bin/ksh
# @(#) public/aix/hacrtmqm, supportpacks, MQHA 1.3 03/12/04 14:15:40
#
# (C) Copyright IBM Corporation 2000, 2003
#
# MC63: WebSphere MQ for AIX - Implementing with HACMP
#
# PLEASE NOTE - This script is supplied "AS IS" with no
# warranty or liability. It is not part of
# any product. Please ensure that you read
# and understand it before you run it. Make
# sure that by running it you will not
# overwrite or delete any important data.
#
# DESCRIPTION:
# hacrtmqm - create a QM that will be amenable to High Availability
#
# You only run this on one node - the one with the disks.
# This is the node where the QMGR will be created. At the end
# of this script, the halinkmqm script will be automatically run
# to prepare various directories and control files.
#
# Then, to prepare the remaining cluster nodes, run the
# halinkmqm script on any other nodes which may also host the QMGR. The
# required command line will be displayed at the end of running
# this hacrtmqm command.
#
# Args:
# Two environment variables must be set before calling the script
# $MQHAFSDATA: mounted filesystem which will hold MQSeries data files
# $MQHAFSLOG: mounted filesystem which will hold MQSeries log files
# Other cmdline parms as for crtmqm (eg -ll, -lf ...)
#
# For an example layout, we could name these 2 filesystems as follows:
# - top component (MQHA) for a single point in the root directory
# where all queue managers on the box will be anchored
# - next component ($qmgr) for the queue manager to be HA'd
# - final component to show the type of data being managed
#
# qmgr1=csq1
# MQHAFSDATA="/MQHA/$qmgr1/data"
# MQHAFSLOG="/MQHA/$qmgr1/log"
#
Appendix A. HA scripts 129
# You do not need to follow these conventions, but this set will work, and
# is fairly easy to comprehend.
# Sanity checks
if [ -z "$MQHAFSDATA" -o -z "$MQHAFSLOG" ]
then
echo "Filesystem environment variables MQHAFSDATA and/or MQHAFSLOG not set"
exit 1
fi
if [ `id -u` -ne 0 ]
then
echo "Must be running as root"
exit 1
fi
# Check we can access the filesystems, and if so, set the permissions on
# the directories. Each queue manager should have its own set of filesystems
# and so the .../qmgrs subdirectory should not already exist (or be empty) in
the
# data directory. We'll use that fact later on to discover the name of
# the directory used for the actual qmgr information.
curdir=`pwd`
for fs in $MQHAFSDATA $MQHAFSLOG
do
cd $fs
if [ $? -ne 0 ]
then
echo "Cannot access filesystem $fs"
exit 1
else
if [ $fs = $MQHAFSDATA ]
then
mkdir $MQHAFSDATA/qmgrs >/dev/null 2>&1
i=`ls -a $MQHAFSDATA/qmgrs | wc -l`
if [ $i -ne 2 ]
then
echo "Directory \"$MQHAFSDATA/qmgrs\" is not empty. It should be!"
exit 1
fi
fi
chown -R mqm:mqm $fs
chmod -R 2775 $fs
fi
done
# Do the actual creation of the queue manager. Needs to be run
# under mqm authority, as root may not be in the mqm group
# - The MQSPREFIX variable forces the data onto the 1st filesystem
130 Highly Available WebSphere Business Integration Solutions
# - The "-ld" option forces logs onto the 2nd filesystem
MQSPREFIX=$MQHAFSDATA su mqm -c "crtmqm -ld $MQHAFSLOG $*"
rc=$?
# We weren't passed the qmgr name directly, so we need to find it from
# the input parms - it's on the end of the line.
while [ ! -z "$1" ]
do
qmgr=$1
shift
done
if [ $rc -eq 0 ]
then
cd $curdir
# Find the mangled directory name
qmgrdir=`ls $MQHAFSDATA/qmgrs`
echo "The halinkmqm script will now be run on this machine. On other"
echo "machines which will potentially takeover this queue manager you"
echo "must run the following command while logged on as \"mqm\"."
echo "\n\t halinkmqm $qmgr $qmgrdir $MQHAFSDATA"
# And actually do it.
su mqm -c "/usr/mqm/hascripts/halinkmqm $qmgr $qmgrdir $MQHAFSDATA"
fi

Get Highly Available WebSphere Business Integration Solutions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.