On RHEL, CentOS, or OEL Oracle Enterprise Linux auto start an Oracle database – tested on 12c

On RHEL, CentOS, or OEL Oracle Enterprise Linux auto start an Oracle database – tested on 11gR2 and 12c
As root:
edit /etc/oratab
and change the N to Y
orcl:/u01/app/oracle/product/12.1.0.2/db_1:Y
then create a file named /etc/init.d/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
# then as root again:
chgrp dba dbora
chmod 750 dbora
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
chkconfig –add dbora

Leave a Comment

Scroll to Top