Automate Oracle Database 11gR2 startup/shutdown in Linux

My environment is CentOS 6.2 64-bit  system. I’ve installed Oracle Database 11gR2 in it. This post provides the steps to automate the start/stop process of Oracle database.

What do we achieve through this:

  1. During Linux OS startup Oracle Database starts up automatically.
  2. During Linux OS shutdown Oracle Database shuts down automatically.
  3. We can start/stop Oracle Database using single line command as root user.

Follow the below steps:

  • Login as root user to linux OS.
  • Update the file /etc/oratab with the following line

<SID>:<ORACLE_HOME>:Y

  • Create the file /etc/init.d/dbora and paste the contents as follows. Specify the values for ORA_HOME and ORA_OWNER as per your environment.

#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.
ORA_HOME=/opt/Oracle/db11gR2/product/11.2.0/dbhome_1
ORA_OWNER=oracle

case “$1” in
‘start’)
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su – $ORA_OWNER -c “$ORA_HOME/bin/dbstart $ORA_HOME”
touch /var/lock/subsys/dbora
;;
‘stop’)
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su – $ORA_OWNER -c “$ORA_HOME/bin/dbshut $ORA_HOME”
rm -f /var/lock/subsys/dbora
;;
esac

  •  In my case I am starting only Oracle Database instance. However if you have other components such as emctl, agentctl etc., then you can append to both start and stop processes.
  • Run the command chkconfig: 35 99 10
  • Run the command chmod 755 /etc/init.d/dbora
  • Run the command chkconfig –add dbora

We’re done. Now to start the database run the command service dbora start as root user. Similarly to stop the database run the command service dbora stop as root user.

Verify the below screenshots for start/stop commands output. In my environment orcl is the SID.

 

References:

Metalink note 222813.1

NOTE: For 10g database, the steps are little different, follow the oracle documentation in such case.

About the Author Mahendra

I am engulfed in Oracle Identity & Access Management domain. I have expertise on providing the optimized solutions for user provisioning, web access management, Single Sign-On and federation capabilities etc., I am also well versed with complex integrations within Identity Management and other product domains. I have expertise on building demos and implementation experience on products Oracle Access Manager, Oracle Adaptive Access Manager, Oracle Entitlement Server, Oracle Virtual Directory, Oracle Internet Directory etc., Look @ my blog: http://talkidentity.blogspot.com

Leave a Comment:

4 comments
David Richardson says December 11, 2012

Check out this new method of integrating automatic startups: http://fusionsecurity.blogspot.com/2012/12/starting-oid-11g-with-upstart.html

Reply
Sahil says December 18, 2012

When I run service dbora start, I am getting the following error:

su: user . does not exit

When I directly run su – $ORA_OWNER -c “$ORA_HOME/bin/dbstart $ORA_HOME” I get the following error:

ORACLE_HOME_LISTNER is not set.

Any suggestions?

Reply
Mahendra says December 19, 2012

Hi Sahil,

make sure you have specified the right user that was used during DB installation. For eg., oracle

Reply
ASIF says December 25, 2012

Dear Oracle Expert,

I hav a question regarding Oracle Apps. I want to know that the scripts that I run one by one to start Oracle EBS can be automated.

I want that when I start my linux machine all Orar EBS get started and when I shutdown my linux machine then Oracle EBS get stopped.

appreciate to find a solution .

Regards,
ASIF

Reply
Add Your Reply

Not found