Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Oracle, Scripts, Veritas

Bounce Veritas HA Cluster resource

Submitted by on December 7, 2005 – 11:01 am 4 Comments

The following is a Korn shell script that can be used from command line or cron to bounce a Veritas HA Cluster resource. This can be useful to resolve certain problems with Oracle databases running under VHA Cluster.

The script has to be executed with root credentials. Sudo can be configured to allow authenticated user to run the db_bounce.ksh without the password.

The script includes configurable parameters for notification:

1.RECEPIENTS – a comma-separated list of e-mail addresses to be used for notification in case of a failure

2.SUBJECT – a subject line to use for e-mail notification

3.ENABLED – set to 0 to disable notification; set to 1 to enable notification

A notification is sent out only if the script fails to bring a resource online, or if the script fails to bounce a resource. A notification e-mail will include relevant error messages, the name of the server, and the name of the resource.

All information and error messages are logged to /var/log/db_bounce.log

To run the script from command line use the following syntax (database dba1t and server delphi1a are used as examples):

1.to view the list of available resources:

sudo /var/adm/bin/db_bounce.ksh -l

2.to view the properties of a particular resource:

sudo /var/adm/bin/db_bounce.ksh -v dba1t

3.to take a resource down:

sudo /var/adm/bin/db_bounce.ksh -d dba1t

4.to bring a resource up:

sudo /var/adm/bin/db_bounce.ksh -u dba1t delphi1a

5.to bounce a resource:

sudo /var/adm/bin/db_bounce.ksh -b dba1t

6.to take a resource down and bring it up on a specific server:

sudo /var/adm/bin/db_bounce.ksh -b dba1t delphi1a

Here’s an example of how to run this script from oracle cron at 3:30am Monday through Friday to bounce the dba1t database:

30 3 * * 1-5 sudo /var/adm/bin/db_bounce.ksh -b dba1t > /dev/null 2>&1

Script:

#!/bin/ksh

# igor@krazyworks.com
# December 6. 2005

# This script allows to restart database resources for
# Veritas Cluster Server service groups. Install this script in
# /var/adm/bin on the Veritas HA cluster nodes and run as root.

# SYNTAX:
# /var/adm/bin/db_bounce.ksh [-udbvl] [resource] [server]

# SUPPORTED SYSTEMS:
#---------------------------------------------------------------
# OS Name	OS Version	Veritas CS Version	Tested
#---------------------------------------------------------------
# SunOS		5.8		3.5			Y
#---------------------------------------------------------------

PARM=$(echo "$#")
ACTION=$(echo "$1")
RESOURCE=$(echo "$2")
SERVER=$(echo "$3")

#---------------------------------------------------------------
# FUNCTIONS
#---------------------------------------------------------------

help() {
	clear
	cat < "$TMP"
		mv "$TMP" "$LOG"
	fi
}

#---------------------------------------------------------------

message() {
	if [ ! $TAIL ]
	then
		TAIL=1
	else
		(( TAIL = TAIL + 1 ))
	fi
	echo "`hostname`	`date +'%Y-%m-%d %T'`	$MSG" >> "$LOG"
	tail -1 "$LOG"
}

#---------------------------------------------------------------

warning() {
	cat < /dev/null 2>&1 ; echo $?` -eq 0 ]
		then
			if [ "$SERVER" ]
			then
				if [ `$HARES -display "$RESOURCE" -attribute State | fgrep -v "#" | awk '{print $3}' | fgrep -cx "$SERVER"` -ne 1 ]
				then
					MSG=$(echo "Server $SERVER is not configured to run $RESOURCE.") ; message
					exit 1
				fi
			fi
		else
			MSG=$(echo "Resource $RESOURCE does not exist.") ; message
			exit 1
		fi
	fi
}

#---------------------------------------------------------------

view_db_list() {
	clear
	$HARES -list | more
}

#---------------------------------------------------------------

view_db_conf() {
	clear
	$HARES -display "$RESOURCE" | more
}

db_down() {
	if [ `$HARES -display "$RESOURCE" -attribute State | grep -v "#" | grep -c ONLINE` -eq 1 ]
	then
		warning
		if [ ! "$SERVER" ]
		then
			SERVER=$($HARES -display "$RESOURCE" -attribute State | grep -v "#" | grep ONLINE | tail -1 | awk '{print $3}')
		fi

		$HACONF -makerw
		$HARES -offline "$RESOURCE" -sys "$SERVER"
		sleep 20
		$HARES -modify "$RESOURCE" Enabled 0

		if [ $? -eq 0 ]
		then
			MSG=$(echo "Changed status of resource $RESOURCE to OFFLINE") ; message
			$HACONF -dump -makero
			exit 0
		else
			MSG=$(echo "Failed to change status of resource $RESOURCE to OFFLINE") ; message
			$HACONF -dump -makero
			exit 1
		fi
	else
		MSG=$(echo "Resource $RESOURCE is already offline.") ; message
		exit 1
	fi
}

#---------------------------------------------------------------

db_up() {
	if [ `$HARES -display "$RESOURCE" -attribute State | grep -v "#" | grep -c ONLINE` -eq 0 ]
	then
		warning
		if [ ! "$SERVER" ]
		then
			MSG=$(echo "No server specified to bring up resource $RESOURCE") ; message
			exit 1
		fi

		$HACONF -makerw
		$HARES -modify "$RESOURCE" Enabled 1
		sleep 20
		$HARES -online "$RESOURCE" -sys "$SERVER"

		if [ $? -eq 0 ]
		then
			MSG=$(echo "Changed status of resource $RESOURCE to ONLINE") ; message
			$HACONF -dump -makero
			exit 0
		else
			MSG=$(echo "Failed to change status of resource $RESOURCE to ONLINE") ; message
			$HACONF -dump -makero
			notify
			exit 1
		fi
	else
		MSG=$(echo "Resource $RESOURCE is already online.") ; message
		exit 1
	fi
}

#---------------------------------------------------------------

db_bounce() {
	if [ `$HARES -display "$RESOURCE" -attribute State | grep -v "#" | grep -c ONLINE` -eq 1 ]
	then
		warning
		if [ ! "$SERVER" ]
		then
			SERVER=$($HARES -display "$RESOURCE" -attribute State | grep -v "#" | grep ONLINE | tail -1 | awk '{print $3}')
		fi

		$HACONF -makerw
		$HARES -offline "$RESOURCE" -sys "$SERVER"
		sleep 20
		$HARES -modify "$RESOURCE" Enabled 0

		if [ $? -eq 0 ]
		then
			MSG=$(echo "Changed status of resource $RESOURCE to OFFLINE") ; message
			sleep 20
			$HARES -modify "$RESOURCE" Enabled 1
			sleep 20
			$HARES -online "$RESOURCE" -sys "$SERVER"

			if [ $? -eq 0 ]
			then
				MSG=$(echo "Changed status of resource $RESOURCE to ONLINE") ; message
				$HACONF -dump -makero
				exit 0
			else
				MSG=$(echo "Failed to change status of resource $RESOURCE to ONLINE") ; message
				$HACONF -dump -makero
				notify
				exit 1
			fi
		else
			MSG=$(echo "Failed to change status of resource $RESOURCE to OFFLINE") ; message
			$HACONF -dump -makero
			notify
			exit 1
		fi
	else
		MSG=$(echo "Resource $RESOURCE is already offline.") ; message
		exit 1
	fi
}

#---------------------------------------------------------------
# RUNTIME
#---------------------------------------------------------------

log
configure
tockens
input_check

case "$ACTION" in
	-d) db_down ;;
	-u) db_up ;;
	-b) db_bounce ;;
	-v) view_db_conf ;;
	-l) view_db_list ;;
	*) help	;;
esac
Print Friendly, PDF & Email

4 Comments »

  • nasty1 says:

    I read on bestplaces.com that both cities ranked in the top ten for places to relocate. I’m curious to hear from ppl who live in these cities. Thanks.

  • Ryan Z says:

    He looks like a bunch of leaves.

  • Elijah luv says:

    My question means like stuff to make it seem like im fashionable (which I am). I already have a mannequin and am using that as an example for answers!

  • Jeracoo L says:

    …a restaurant (ha, only spelt it wrong three times this time) or a bar?

    What kind of bar/restaurant is it?

    BQ – If you had to enter an eating competition, what food would you pick?
    BQ2 – Have you got any amusing child hood memories?

    RBQ – Books and authors people are very unhelpful, soooo are any of you fans of Oscar Wilde as an author?

Leave a Reply

%d bloggers like this: