#!/bin/ksh
#############################
# Put program variable here
#
db1=orcl
db2=RMAN
###############################
while [ : ] ; do
while [ : ] ; do
echo ' ';
echo '*******************************************';
echo ' M E N U ';
echo '*******************************************';
echo ' 1. Stop Cluster '
echo ' 2. Stop database '
echo ' 3. Stop instance '
echo ' 4. Start database '
echo ' 5. Start instance '
echo ' 6. Start Cluster '
echo ' 7. Cluster status '
echo ' 8. Databases status '
echo ' 9. OCFS2 status '
echo ' 10. Show OCR backups '
echo ' 11. Show RMAN backups'
echo ' 99. EXIT '
echo '*******************************************';
echo ' ';
read reply
case $reply in
1)
print ' +---------------------------+'
print ' | STOP CLUSTER |'
print ' +---------------------------+'
print '*** You choose to stop Oracle cluster services. ***'
print '*** By stopping Oracle cluster services all available database will be stop ***'
print 'To continue press [Y/y]'
read ans
if [[ $ans == @(Y|y) ]]; then
srvctl stop database -d $db1 -o immediate
srvctl stop database -d $db2 -o immediate
/etc/init.d/init.crs stop
$ORA_CRS_HOME/bin/crs_stat -t
fi
break ;;
2)
print ' +---------------------------+'
print ' | STOP DATABASE |'
print ' +---------------------------+'
print '*** You choose to stop Oracle database , this action will stop all instances in all nodes ***'
print 'To continue press [Y/y]'
read ans
if [[ $ans == @(Y|y) ]]; then
print '\n Enter the database name \c'
read db
srvctl stop database -d $db -o immediate
fi
break ;;
3)
print ' +---------------------------+'
print ' | STOP INSTANCE |'
print ' +---------------------------+'
print '*** You choose to stop Oracle instance on this node ***'
print 'To continue press [Y/y]'
read ans
if [[ $ans == @(Y|y) ]]; then
print '\n Enter the database name \c'
read db
print '\n Enter the instance name \c'
read instance
srvctl stop instance -d $db -i $instance
fi
break ;;
4)
print ' +---------------------------+'
print ' | START DATABASE |'
print ' +---------------------------+'
print '\n Enter the database name \c'
read db
srvctl start database -d $db -o open
break ;;
5)
print ' +---------------------------+'
print ' | DATABASE STATUS |'
print ' +---------------------------+'
print '\n Enter the database name \c'
read db
print '\n Enter the instance name \c'
read instance
srvctl start instance -d $db -i $instance
break ;;
6)
print ' +---------------------------+'
print ' | START CLUSTER |'
print ' +---------------------------+'
print ' Starting cluster components , and all avaible databases '
/etc/init.d/init.crs start
srvctl start database -d $db1 -o open
srvctl start database -d $db2 -o open
srvctl start service -d ORCL -s TEST
srvctl start service -d RMAN -s RMAN_CATALOG
$ORA_CRS_HOME/bin/crs_stat -t
break ;;
7)
print ' +---------------------------+'
print ' | CLUSTER STATUS |'
print ' +---------------------------+'
$ORA_CRS_HOME/bin/crs_stat -t
break ;;
8)
print ' +---------------------------+'
print ' | DATABASE STATUS |'
print ' +---------------------------+'
if ps -aef | grep pmon | grep $db1 > /dev/null ; then
print "Database $db1 is Up."
else
print "Database $db1 is down."
exit 1
fi
if ps -aef | grep pmon | grep $db2 > /dev/null ; then
print "Database $db2 is Up."
else
print "Database $db2 is down."
exit 1
fi
break ;;
9)
print ' +---------------------------+'
print ' | OCFS2 STATUS |'
print ' +---------------------------+'
/etc/init.d/o2cb status
break ;;
10) print 'Show OCR backups'
break ;;
99) exit
break ;;
esac
done
done