If you install DB2 pureScale in Linux, the Fast I/O Fencing does not get enabled automatically. If you refer to Knowledge Center for DB2, you will find number of steps to enable fast I/O fencing.
After DB2 instance is created and databases are created, I usually run this script to automate this feature.
You can download the script from here. Disclaimer: Use at your own risk.
One should not trust their own fingers and eyes while doing DBA work so it is always better to reply upon automation that can do the work.
Eyes see things accurately but mind can interpret it differently. For two finger typist like me, my left finger sometime types faster than the right finger so I do not trust my own fingers for typing.
#!/bin/bash
# Vikram Khatri (vikram.khatri at IBM Company in US)
# enable SCSI-3 PR at GPFS level for Linux
# ./enablescsipr <yes|no>
# ./enablescsipr yes
MMBIN=/usr/lpp/mmfs/bin
RSCTBIN=/usr/sbin/rsct/bin
PRCAP=/tmp/prcapdevices
if [ "$#" != "1" ]; then
echo "Usage: $0 yes|no" 1>&2
echo "Usage: $0 yes" 1>&2
echo " yes - mmchconfig usePersistentReserve=yes will be run" 1>&2
echo " no - mmchconfig usePersistentReserve= will be run" 1>&2
exit 1
fi
SCSIPR=$1
if [ "$SCSIPR" != "yes" -a "$SCSIPR" != "no" ] ; then
echo "Valid value for second argument is yes or no" 1>&2
exit
fi
echo =======================================================================
echo Find db2ls and if not found then exit
echo =======================================================================
which db2ls > /dev/null 2>&1
if [ $? -eq 1 ] ; then
echo "db2ls not found. Exiting ...." 1>&2
exit 1
fi
DB2INSTALLDIR=`db2ls -c | awk 'BEGIN {FS=":"} END {print $1}'`
echo =======================================================================
echo "DB2 install dir = $DB2INSTALLDIR"
INSTANCE=`$DB2INSTALLDIR/bin/db2ilist`
echo "DB2 Instance Name = $INSTANCE"
INSTHOME=`cat /etc/passwd | grep $INSTANCE | awk 'BEGIN{FS=":"} {print $6}'`
echo "DB2 Instance Home = $INSTHOME"
DB2NODES=`readlink -f $INSTHOME/sqllib/db2nodes.cfg`
echo "db2nodes.cfg location = $DB2NODES"
echo =======================================================================
HOSTLIST=`cat $INSTHOME/sqllib/db2nodes.cfg | awk '{print $2}' | sort | uniq`
if [ "$HOSTLIST" == "" ] ; then
echo "Unable to read db2nodes.cfg file. Looks like GPFS is down" 1>&2
exit 1
fi
GPFSFS=(`$DB2INSTALLDIR/bin/db2cluster -cfs -list -filesystem -zout \
| grep -v END_LIST | awk 'BEGIN {FS=","} { print $1}'`)
> $PRCAP
for ((i=0; i<${#GPFSFS[@]}; i++))
do
FS=${GPFSFS[i]}
echo "Finding GPFS disk for $FS"
GPFSDISK=(`$DB2INSTALLDIR/bin/db2cluster -cfs -list -filesystem $FS -disk -zout \
| grep -v END_LIST | sed -e 's/.*\///' | awk 'BEGIN {FS=","}{print $1}'`)
for ((j=0; j<${#GPFSDISK[@]}; j++))
do
DISK=${GPFSDISK[j]}
if [ "$DISK" == "" ] ; then
echo "Unable to determine GPFS disk name" 1>&2
echo "Command used to determine the disk name was" 1>&2
echo "db2cluster -cfs -list -filesystem $FS -disk" 1>&2
exit 1
fi
echo "GPFS Disk Name = $GPFSDISK"
TSPRINQ=`$MMBIN/tsprinquiry $DISK | tr -d ' '`
echo "Writing $TSPRINQ to prcapdevices"
echo $TSPRINQ >> $PRCAP
done
done
for host in $HOSTLIST
do
echo "Copying prcapdevices to $host" 1>&2
scp $PRCAP $host:/var/mmfs/etc/
done
echo =======================================================================
echo "Stop db2 instance" 1>&2
NODELIST=`cat $INSTHOME/sqllib/db2nodes.cfg | awk '{print $1}'`
for node in $NODELIST
do
echo "Executing db2stop $node force" 1>&2
su -l $INSTANCE -c "source ~/.bashrc;db2stop $node force"
done
echo =======================================================================
echo "Sleeping for 10 seconds"
sleep 10
for host in $HOSTLIST
do
echo "Stop db2 instance on $host" 1>&2
su -l $INSTANCE -c "source ~/.bashrc;db2stop instance on $host"
done
echo "Sleeping for 5 seconds"
sleep 5
export CT_MANAGEMENT_SCOPE=2
echo "Put CM into maintenance mode" 1>&2
$DB2INSTALLDIR/bin/db2cluster -cm -enter -maintenance -all
echo "Put CFS into maintenance mode" 1>&2
$DB2INSTALLDIR/bin/db2cluster -cfs -enter -maintenance -all
echo "Sleeping for 5 seconds"
sleep 5
echo =======================================================================
if [ "$SCSIPR" == "yes" ] ; then
echo "Running mmchconfig usePersistentReserve=yes"
$MMBIN/mmchconfig usePersistentReserve=yes
else
echo "Running mmchconfig usePersistentReserve="
$MMBIN/mmchconfig usePersistentReserve=
fi
if [ "$SCSIPR" == "yes" ] ; then
echo "Running mmlsnsd -X. Check remark column for pr=yes" 1>&2
echo =======================================================================
$MMBIN/mmlsnsd -X
echo =======================================================================
fi
echo "Get CM out of maintenance mode" 1>&2
$DB2INSTALLDIR/bin/db2cluster -cm -exit -maintenance -all
sleep 10
echo "lsrpdomain" 1>&2
$RSCTBIN/lsrpdomain
echo "lsrpnode" 1>&2
$RSCTBIN/lsrpnode -B -Q -P
echo "Sleeping for 10 seconds"
sleep 10
echo "Get CFS out of maintenance mode" 1>&2
$DB2INSTALLDIR/bin/db2cluster -cfs -exit -maintenance -all
echo "Check Status of CFS hosts" 1>&2
$DB2INSTALLDIR/bin/db2cluster -cfs -list -host -state
echo =======================================================================
for i in {1..200}
do
echo "$i Waiting for db2nodes.cfg to become available" >&2
if [ -a $DB2NODES ] ; then
echo "db2nodes.cfg is available now."
for host in $HOSTLIST
do
echo "Start db2 instance on $host" 1>&2
su -l $INSTANCE -c "source ~/.bashrc;db2start instance on $host"
done
echo "db2start 129"
su -l $INSTANCE -c "source ~/.bashrc;db2start 129"
echo "db2start 128"
su -l $INSTANCE -c "source ~/.bashrc;db2start 128"
echo "db2start"
su -l $INSTANCE -c "source ~/.bashrc;db2start"
break;
fi
sleep 10
done
echo =======================================================================
db2cluster -cfs -list -configuration | grep usePersistentReserve
echo =======================================================================