Oracle Start up script
Usually oracle database can be started or stopped by logging in to the DB as sysdba and applying "startup" and "shutdown immediate" commands. Here i am providing you a script to configure the same in /etc/init.d/ and we can start, stop and check the status of the oracle with PID details .
Sample script
*********************************************************************************
#!/bin/bash
# chkconfig: 35 95 1
# description: init script to start/stop oracle database 10g, TNS listener
#
#
# match these values to your environment:
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/product/11.2.0/dbhome_1
export OH=$ORACLE_HOME
export JAVA_HOME=$OH/jdk
export PATH=$OH/bin:$JAVA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export ORACLE_SID=MBDB
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
echo "Starting Oracle database ..."
su - "$ORACLE_USER" <<EOO
lsnrctl start
sqlplus /nolog <<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
EOO
;;
stop)
echo "Stopping Oracle database ..."
su - "$ORACLE_USER" <<EOO
emctl stop dbconsole
sqlplus /nolog <<EOS
connect / as sysdba
shutdown immediate
EOS
lsnrctl stop
EOO
;;
restart){
$0 stop
$0 start
}
;;
status)
a=`ps -ef |grep oracle |grep LISTENER |awk -F " " '{print $2}'|head -1`
if [ "$a" > 0 ];then
echo "Oracle is working fine with pid $a"
else
echo "Oracle is not working"
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac
*********************************************************************************
Startup output
stop output
status
This script will be useful while configuring oracle in HA ( High Availability ) setups
No comments:
Post a Comment