Saturday, August 16, 2014

Oracle - automatic startup and shutdown scripts

DBAs can rest when server admins restart the server. Usually it engages both the teams when server is taken down for maintenance. By deploying the scripts, DBAs need not shutdown and startup the databases and services manually.

The scripts I have used have been taken from Tim Halls' oracle-base. The scripts from his site works when there is single database. I have modified the scripts so that they can be used when the server has multiple databases. The only requirement is that all database names should be available in /etc/oratab as shown below:



In the above picture, one database name is commented and one is given "N". The script ignores these unwanted databases and takes into account only active databases.

The scripts need not need any specific modification except that you may need to edit the script and place the location of your bash profile you want to use.

Download these 3 files:

dbora
startup.sh
shutdown.sh

copy dbora file to /etc/init.d/ 

and then execute:

chmod 750 /etc/init.d/dbora
 
  
Add dbora to the run level as below :

chkconfig --add dbora
 

This ensures the script runs when the host server goes for startup or shutdown.

 Note: the above 2 steps dealing with dbora file is done by root user


copy startup.sh and shutdown.sh to /app/oracle/scripts/  or any other desired location and test by restarting the server. Check the log startup_shutdown.log in the same location.


Cheers!!