Quantcast
Channel: Oracle Trainings for Apps & Fusion DBA
Viewing all articles
Browse latest Browse all 1568

Automate Oracle Database 11gR2 startup/shutdown in Linux

$
0
0

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.


Viewing all articles
Browse latest Browse all 1568

Trending Articles