Some notes for DBAs
Date: Thu, 4 Feb 1993 13:34:47 GMT
Message-ID: <1993Feb4.133447.11271_at_wescom.kharkov.ua>
Hereinbelow are the texts of four shell files. They make up all ORACLEs (defined in your /etc/oratab) startup at system startup moment (prompting before to do that ) and shutdown at system shutdown. They are enough succesfully working on our SCO SVR2 starting three instances and downing them. It's clear that these texts are very raw ones, hence I would be very appreciated for any critical comments on this subject. I hope also they could be useful for DBAs who need to start and shut instances everymorning and everynight respectively.
alex_at_wescom.kharkov.ua
#*******************************************************************************
#*************************** /etc/rc2.d/S95oracle ******************************
#*******************************************************************************
ORACLE_TABLE="/etc/oratab"
ORACLE_STARTUP="/etc/orastart"
awk '
FS = ":" ora = ARGV[2] colours = "blue:magenta:brown:black:lt_blue:lt_magenta:yellow:gray:" \ "cyan:white:green:red:lt_cyan:hi_white:lt_green:lt_red" bg_colors = "black:black:black:black:black:black:black:black:" \ "black:black:black:black:black:black:black:black" fg_colors = "yellow:lt_blue:lt_cyan:lt_red:lt_magenta:lt_green:" \ "hi_white:blue:magenta:brown:black:gray:cyan:white:green:red" func number() { if ( j < 16 ) j++ else j = 1 } func set_color() { bg_msg = bg_color[j] fg_msg = fg_color[j] bg_unx = bg_color[j] fg_unx = bg_color[j] } { split(bg_colors,bg_color) split(fg_colors,fg_color) for (i=1; i<=NR; i++) if ($1 !~ "#" && FILENAME !~ ARGV[2] && NF == 3) { number() set_color() cmd = ora" "$1" "$2 cmd = cmd" "fg_msg" "bg_msg cmd = cmd" "fg_unx" "bg_unx system(cmd) next } else next }
' $ORACLE_TABLE $ORACLE_STARTUP
#*******************************************************************************
#****************************** /etc/orastart **********************************
#*******************************************************************************
############################################################################### # # Start up oracle and orasrv
#
###############################################################################
PATH=.:/bin:/etc:/usr/bin:/usr/dbin:/usr/lbin:/usr/local/bin; export PATH
setcolor $3 $4
echo "\n Do you wish startup ORACLE Instance ( "$1" ) ?" echo " Please, answer 'y' or 'n'"
setcolor white black
while read ANS
do
case "$ANS" in y|Y) ANS=y break;; n|N) ANS=n break;; *) setcolor lt_red black echo "Please, answer 'y' or 'n' !" esac
setcolor white black
done
if [ $ANS = y ]
then
ORACLE_GROUP=`ls -dg $2 | awk '{ print $3 }'`; export ORACLE_GROUP ORACLE_OWNER=`ls -do $2 | awk '{ print $3 }'`; export ORACLE_OWNER ORACLE_SID=$1; export ORACLE_SID ORACLE_HOME=$2; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/lbin; export PATH
if [ -r $ORACLE_HOME/dbs/sgadef$ORACLE_SID.dbf ]
then rm $ORACLE_HOME/dbs/sgadef$ORACLE_SID.dbf
fi
su $ORACLE_OWNER -c "sqldba command=startup" | tee $ORACLE_HOME/log/orastart.$ORACLE_SID 2>&1
su root -c "tcpctl start" | tee $ORACLE_HOME/log/oratcp.$ORACLE_SID 2>&1
su $ORACLE_OWNER -c "tcptlictl start" | tee $ORACLE_HOME/log/oratli.$ORACLE_SID 2>&1
fi
#*******************************************************************************
#***************************** /etc/rc0.d/K40oracle ****************************
#*******************************************************************************
ORACLE_TABLE="/etc/oratab"
ORACLE_SHUTDOWN="/etc/orashut"
awk '
FS = ":" ora = ARGV[2] colours = "blue:magenta:brown:black:lt_blue:lt_magenta:yellow:gray:" \ "cyan:white:green:red:lt_cyan:hi_white:lt_green:lt_red" bg_colors = "black:black:black:black:black:black:black:black:" \ "black:black:black:black:black:black:black:black" fg_colors = "yellow:lt_blue:lt_cyan:lt_red:lt_magenta:lt_green:" \ "hi_white:blue:magenta:brown:black:gray:cyan:white:green:red" func number() { if ( j < 16 ) j++ else j = 1 } func set_color() { bg_msg = bg_color[j] fg_msg = fg_color[j] bg_unx = bg_color[j] fg_unx = bg_color[j] } { split(bg_colors,bg_color) split(fg_colors,fg_color) for (i=1; i<=NR; i++) if ($1 !~ "#" && FILENAME !~ ARGV[2] && NF == 3) { number() set_color() cmd = ora" "$1" "$2 cmd = cmd" "fg_msg" "bg_msg cmd = cmd" "fg_unx" "bg_unx system(cmd) next } else next }
' $ORACLE_TABLE $ORACLE_SHUTDOWN
#*******************************************************************************
#***************************** /etc/orashut ************************************
#*******************************************************************************
############################################################################### # # Shutdown oracle and orasrv
#
###############################################################################
PATH=.:/bin:/etc:/usr/bin:/usr/dbin:/usr/lbin:/usr/local/bin; export PATH
# /bin/su root -c "/bin/ps -e" 2>/dev/null | \ # /usr/bin/fgrep orasrv > /dev/null 2>&1
if [ $? -eq 0 ]
then
ORACLE_GROUP=`ls -dg $2 | awk '{ print $3 }'`; export ORACLE_GROUP ORACLE_OWNER=`ls -do $2 | awk '{ print $3 }'`; export ORACLE_OWNER ORACLE_SID=$1; export ORACLE_SID ORACLE_HOME=$2; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/lbin; export PATH
su $ORACLE_OWNER -c "tcpctl stop" | tee -a $ORACLE_HOME/log/oratcp.$ORACLE_SID 2>&1 su $ORACLE_OWNER -c "tcptlictl stop" | tee -a $ORACLE_HOME/log/oratli.$ORACLE_SID 2>&1 fi
PATH=.:/bin:/etc:/usr/bin:/usr/dbin:/usr/lbin:/usr/local/bin; export PATH
# /bin/su root -c "/bin/ps -e" 2>/dev/null | \ # /usr/bin/fgrep oracle > /dev/null 2>&1
if [ $? -eq 0 ]
then
ORACLE_GROUP=`ls -dg $2 | awk '{ print $3 }'`; export ORACLE_GROUP ORACLE_OWNER=`ls -do $2 | awk '{ print $3 }'`; export ORACLE_OWNER ORACLE_SID=$1; export ORACLE_SID ORACLE_HOME=$2; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/lbin; export PATH
su $ORACLE_OWNER -c "sqldba command=shutdown immediate" | tee -a $ORACLE_HOME/log/orastart.$ORACLE_SID 2>&1 fi Received on Thu Feb 04 1993 - 14:34:47 CET