This post is to provide a script to auto-start Oracle Instances on Linux upon server restart.
First step would be to configure /etc/oratab file as per your requirement, oratab file is in the following format:
<DB NAME>:<ORACLE HOME>:<Y|N>
The last letter tells oracle if the database need to restarted or not, so we would change the last letter to Y of all the databases that we want to start on instance restart.
Second step would be to create a /etc/init.d/oracle script as follows:-
chkconfig: 345 99 10
description: Oracle auto start-stop script.
#Set ORA_HOME to be equivalent to the $ORACLE_HOME from which you wish to execute dbstart and dbshut;
#Set ORA_OWNER to the user id of the owner of the Oracle database in ORA_HOME. path to oracle home (needed only to check if dbstart exists)
ORA_HOME=<Specify absolute Oracle Home path here>
ORACLE_SID=<SID of the DB you want to start>
if [ ! -f $ORA_HOME/bin/dbstart ]
echo "Oracle startup: cannot start"
case "$1" in
# Start the Oracle database and listener:
# Remove "&" if you don't want startup as a background process.
# at this point we have $ORACLE_HOME env variable set
su $ORA_OWNER -c "dbstart $ORACLE_HOME" &
# Stop the Oracle database and listener:
su $ORA_OWNER -c "dbshut $ORACLE_HOME"
rm -f /var/lock/subsys/oracle
Once the script is created (Please make sure that the Oracle Home & Oracle SID is specified) execute following commands:
chmod 750 /etc/init.d/oracle
chkconfig --add oracle
chkconfig --level 2345 oracle on
chkconfig --level 06 oracle of
That’s it all your databases should now start upon the server restart.
NOTE: In case of PDB please ensure that you have saved the PDB state else the PDBs would be started in mounted state and not READ WRITE state.
ALTER PLUGGABLE DATABASE <DB NAME> SAVE STATE;