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:
- During Linux OS startup Oracle Database starts up automatically.
- During Linux OS shutdown Oracle Database shuts down automatically.
- 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