Oracle Startup script used for Automatic start up of oracle db after rebooting the machine. I have already explained how to install oracle 11g in previous posts and just note how to add a startup script with respect to that settings
For automatically restart the oracle after system reboot create a file called oracle ( any name ) in /etc/init.d/ and give executable permission and paste the code into it. And make a link to /etc/rc5.d/ for that
# cd /etc/rc5.d
# ll
# ln -s ../init.d/oracle S86oracle
# vim /etc/init.d/oracle —– and paste the below script into it. and then make the above link into it.
# Oracle Startpup script
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle
case “$1” in
‘start’) #If the system is starting, then…
echo -e “\e[34mStarting ORACLE…\e[0m”
ORA_OWNER=oracle
case “$1” in
‘start’) #If the system is starting, then…
echo -e “\e[34mStarting ORACLE…\e[0m”
#Start the listener
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl start 2>&1> /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl start 2>&1> /dev/null”
#Start the database
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbstart 2>&1 > /dev/null”
# su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole 2>&1 > /dev/null” #Start OEM
;;
‘stop’) #If the system stops, that is we’re shutting down our OS, then…
echo -e “\e[34mStopping ORACLE…\e[0m”
# su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbshut 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop 2>&1 > /dev/null”
;;
esac
# su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole 2>&1 > /dev/null” #Start OEM
;;
‘stop’) #If the system stops, that is we’re shutting down our OS, then…
echo -e “\e[34mStopping ORACLE…\e[0m”
# su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbshut 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop 2>&1 > /dev/null”
;;
esac
OR
# Oracle Startpup script
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
case “$1” in
‘start’) #If the system is starting, then…
echo -e “e[34mStarting ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl start 2>&1> /dev/null”
#Start the listener
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbstart 2>&1 > /dev/null”
#Start the database
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole 2>&1 >
/dev/null” #Start
OEM
;;
‘stop’) #If the system is stops, that is we’re shutting down our OS,
then…
echo Oracle startup script
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
case “$1” in
‘start’) #If the system is starting, then…
echo -e “e[34mStarting ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl start 2>&1> /dev/null”
#Start the listener
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbstart 2>&1 > /dev/null”
#Start the database
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole 2>&1 >
/dev/null” #Start
OEM
;;
‘stop’) #If the system is stops, that is we’re shutting down our OS,
then…
echo -e “e[34mStopping ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole 2>&1 >
/dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbshut 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop 2>&1 > /dev/null”
;;
esac
-e “e[34mStopping ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole 2>&1 >
/dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbshut 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop 2>&1 > /dev/null”
;;
esac
ORA_OWNER=oracle
case “$1” in
‘start’) #If the system is starting, then…
echo -e “e[34mStarting ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl start 2>&1> /dev/null”
#Start the listener
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbstart 2>&1 > /dev/null”
#Start the database
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole 2>&1 >
/dev/null” #Start
OEM
;;
‘stop’) #If the system is stops, that is we’re shutting down our OS,
then…
echo Oracle startup script
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
case “$1” in
‘start’) #If the system is starting, then…
echo -e “e[34mStarting ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl start 2>&1> /dev/null”
#Start the listener
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbstart 2>&1 > /dev/null”
#Start the database
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole 2>&1 >
/dev/null” #Start
OEM
;;
‘stop’) #If the system is stops, that is we’re shutting down our OS,
then…
echo -e “e[34mStopping ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole 2>&1 >
/dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbshut 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop 2>&1 > /dev/null”
;;
esac
-e “e[34mStopping ORACLE…e[0m”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole 2>&1 >
/dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/dbshut 2>&1 > /dev/null”
su – $ORA_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop 2>&1 > /dev/null”
;;
esac
Change the path according to your path
Save the file as oracle in /etc/init.d directory and make it executable. This script starts the listener, database and enterprise manager.
# vim /etc/init.d/oracle
# chmod 755 /etc/init.d/oracle
Recent Comments