Oracle 12c Database Auto Start on RHEL 6 and others

# To auto start Oracle 12c Database on RHEL 6 and others I did this (there are other methods):
# as root
# update the “N” in /etc/oratab to “Y” for the instance you want to auto-start
# add the following file to /etc/init.d as root
dbora
#! /bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! “$2” = “ORA_DB” ] ; then
runuser -l $ORACLE $0 $1 ORA_DB
if [ “$PLATFORM” = “Linux” ] ; then
touch /var/lock/subsys/dbora
fi
exit
fi
#
case $1 in
‘start’)
$ORACLE_HOME/bin/dbstart $ORACLE_HOME &
;;
‘stop’)
$ORACLE_HOME/bin/dbshut $ORACLE_HOME &
rm -f /var/lock/subsys/dbora
;;
*)
echo “usage: $0 {start|stop}”
exit
;;
esac
#
exit
NOTE: ***** – your ORACLE_HOME in the script above maybe different – adjust if necessary – and maybe your Linux account that you installed oracle from is not named “oracle” adjust that as well if necessary
After the file has been created change it’s owner and privs as follows
chgrp dba dbora
chmod 750 dbora
# create symbolic links
ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
add the service
chkconfig –add dbora
Note: the dbora script calls $ORACLE_HOME/bin/dbstart and dbshut – I modified neither
reboot RHEL
reboot
# login to Linux as oracle – check that it worked
lsnrctl status
sqlplus / as sysdba
MFer

Leave a Comment

Scroll to Top