Every Oracle system has an “/etc/oratab” file, which is created after Oracle installation by the Root.sh script. This file contains entries for every database on the system. “Setup Oracle to Startup Automatically if the System is Restarted”
To complete this process, you need to log in with the root user.
Table of Contents
Setup Oracle to Startup Automatically if the System is Restarted
Follow the below steps carefully to Setup Oracle to Startup Automatically if the System is Restarted.
Step 1. Edit the “oratab” file
The “oratab” file contains an entry with the database name and the ORACLE_HOME location.
[oracle@localhost ~]$ cat /etc/oratab
dgtech:/u01/app/oracle/product/19.3.0/dbhome_1:N
Replace “N” with “Y” like below:
dgtech:/u01/app/oracle/product/19.3.0/dbhome_1:Y
Step 2. Create dbora.sh
Now create a dbora.sh file inside the “/etc/init.d/” directory and add the below entries in it.
#vi /ete/init.d/dbora.sh
# add the below lines:
#!/bin/sh
ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
ORACLE_OWNER=oracle
if [ "$1" = "start" ] ; then
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart &
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
exit 0
fi
if [ "$1" = "stop" ] ; then
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut &
exit 0
fi
echo "Usage: $0 [start|stop]"
Replace the ORACLE_OWNER name, ORACLE_HOME and add “dbstart“,”dbshut” and “lsnrctl“.
Step 3. Link dbora.sh file to /etc/rc directory
Names starting with “S” indicate scripts that are called at startup; names starting with “K” indicate scripts that are called at shutdown time.
# ln -s /etc/init.d/dbora.sh /etc/rc0.d/K10dbora.sh
# ln -s /etc/init.d/dbora.sh /etc/rc2.d/S99dbora.sh
All set now. Just restart your machine and check if the Database and Listener are up automatically.
I hope you found this article useful, if yes please write your words in comment box.
This article source is oracle.com official document id Doc ID 105957.1
Read: EXECUTION PLAN in Oracle Database