Monday, January 19, 2009

Automating startup/shutdown of Oracle database on Linux

The following script can be used to automate database startup/shutdown of an Oracle database on Linux platform.

- update the oratab file under /etc or /var/opt/oracle


where Y states that the database to be started up/shutdown

- Create the service script in the following location:

vi dbora

- Modify the following script to match the specific environment and This becomes the content of the "dbora" service script.


# chkconfig: 35 99 10
# description: Starts and stops Oracle processes

LOG_FILE='touch /var/lock/subsys/dbora'

case "$1" in
'start') # Start the Oracle database,listener and apps
su - $ORADEV_OWNER -c "$DB_SCRIPTS/ start"
su - $ORADEV_OWNER -c "$DB_SCRIPTS/ start SID"
sleep 100
su - $APPSDEV_OWNER -c "$APPS_SCRIPTS/ apps/apps"
'stop') # Stop the Oracle database,listener and apps
su - $APPSDEV_OWNER -c "$APPS_SCRIPTS/ apps/apps"
sleep 300
su - $ORADEV_OWNER -c "$DB_SCRIPTS/ stop immediate"
rm /var/lock/subsys/dbora


Modify the sleep time according to the speed of the server and the time taken by the server to startup and shutdown the instance.

- Set script permissions:

chmod 755 /etc/init.d/dbora

- Register the Service

at the terminal prompt, issue the following command.

chkconfig --add dbora
The chkconfig creates the following symbolic links,


* /etc/init.d/rc0.d/K10dbora
* /etc/init.d/rc1.d/K10dbora
* /etc/init.d/rc2.d/K10dbora
* /etc/init.d/rc3.d/S99dbora
* /etc/init.d/rc4.d/K10dbora
* /etc/init.d/rc5.d/S99dbora
* /etc/init.d/rc6.d/K10dbora

On Red Hat Advanced Server:

* /etc/rc.d/rc0.d/K10dbora
* /etc/rc.d/rc1.d/K10dbora
* /etc/rc.d/rc2.d/K10dbora
* /etc/rc.d/rc3.d/S99dbora
* /etc/rc.d/rc4.d/K10dbora
* /etc/rc.d/rc5.d/S99dbora
* /etc/rc.d/rc6.d/K10dbora

The symbolic links are not created in SLES8 and after with the 'chkconfig -add' command. To have the symbolic links created run the following in addition:

/sbin/chkconfig --set dbora 35

- Now the instance will startup automatically when Linux boots up.


RogerS said...

I used your rc script as a template. I had to modify it as the database is on another node from the application tier. Anyways, I found that the call to the with the correct apps/pwd does not work under bash, Linux redhat 4 update 5 as I get an error > ERROR_MSG="Database connection could not be established. Either the database is down or the APPS credentials supplied are wrong." < in the adstrtal.log. If I execute the su - applmgr -c command with the explicit path, execute of the and the apps/ works from the root user. But not when executed by the rc5.d S99oracleapps scripts?
Strange but true.
Roger Sager

RogerS said...

Hi everyone...
Further news on Automating the startup/shutdown of Oracle DB and Apps...
1. I found that Oracle has bug checked the for the AutoConfig process as this script is run for "start" then calls adstrtdb.sql. However, in the adstrtdb.sql the startup command has a hard coding to use the pfile= option to source the initSID.ora file. Instead, there should be no pfile= option, then the startup would source the spfileSID.ora first, failing that look for the initSID.ora file. So this is something to be aware of, especially, if your spfile and init file are different. There are several work arounds...the simplest is to remove the pfile option from the adstrtdb.sql script unitl Oracle release a fix.
2. The original posting rc script will probably work under a run level reboot condition if the Database and Oracle Apps tiers are on the same node/server. However, in my case they were separate. The 10G DB was on node 1 and the
R12.0.4 Apps was on node 2. For a reboot to run level 5 the " apps/apps" would not work because there is a sql password check at the beginning of which fails with the ORA-12560: TNS:protocol adapter error. This happens even if the Database and listener on node 1 are up and running. Oracle will not admit that they have a problem yet, but my work around is to not call the, but instead call the individual start up scripts in the appropriate order...such as
1- start
2- start
3- start
4- start
5- start
6- start
7- start apps/apps
8- start
...then on "stop" call them in the reverse order. This work for me under Redhat 4.5, Oracle 10G, and r12.0.4 Apps.
Good Luck

tikitodo said...

there are many ways of fix broken pdf links, try this application if you’d like to get better results