Monday, March 19, 2012

Auto startup and shutdown oracle database in linux

Auto startup and shutdown oracle database in linux or sun solaris
=================================================================
Down this file
https://www.dropbox.com/s/yrrpy0eta8qmdt3/auto_startup%20database%20in%20linux.txt

1) change a flag ( from N to Y) for auto starup the instance (there may be more than one instance, you should change every instance flag)

In Linux
===========

[ oratab file will create when you run (two script at installation of oracle finishing time) with root user ]

root# vi /etc/oratab

orcl:/d02/oracle/ora102:Y


In sun solaris
===================

root# vi /var/opt/oracle/oratab

orcl:/d02/oracle/ora102:Y


2)

First create(with oracle user) two "start_db" and "stop_db" script
in your $ORACLE_HOME/bin that starts and stop the db.
scripts are below... be careful about copy/paste.try to write it
with your own hand in linux.



-------------------start_db script

#!/bin/bash
# Start the Oracle Database and listeners
su - oracle< lsnrctl start
sqlplus /nolog< connect / as sysdba
startup
EOS
#emctl start dbconsole
#isqlplusctl start
EOO



---------------stop_db script


#!/bin/bash
# Stop the Oracle Database and linteners
su - oracle< lsnrctl stop
sqlplus /nolog< connect / as sysdba
shutdown immediate
EOS
#emctl stop dbconsole
#isqlplusctl stop
EOO



3) (with root user)

add to the /etc/rc3.d/S99local script something like:


#!/bin/sh
# chkconfig: 345 99 10
case "$1" in
'start') su - oracle -c start_db ;;
'stop') su - oracle -c stop_db ;;
esac

or

you can make a script like /etc/init.d/db_start_stop
and give the following permission and association.

chmod 750 /etc/init.d/db_start_stop

chkconfig --add db_start_stop




4) for test your script with root user

-----------------------------
#!/bin/sh
# chkconfig: 345 99 10
case "$1" in
'start') su - oracle -c start_db ;;
'stop') su - oracle -c stop_db ;;
esac
--------------------------------

(note: make a script with above code name in
"/etc/init.d/db_start_stop"


#sh /etc/init.d/db_start_stop start
#sh /etc/init.d/db_start_stop stop


----------------extra---for--me--only----------------------

============================================================================
i was facing "standard in must be a tty" this message when testing to run
these commands
#sh /etc/init.d/db_start_stop start
#sh /etc/init.d/db_start_stop stop

solution:-
I am making change in this script
#!/bin/sh
# chkconfig: 345 99 10
case "$1" in
'start') su - oracle -c start_db ;;---change----su - root -c /oracle_home_details/bin/start_db ;;
'stop') su - oracle -c stop_db ;; ---change----su - root -c /oracle_home_details/bin/stop_db ;;
esac


==========================================================

note : for Associating the db_start_stop service with the appropriate run levels and set it to auto-start using the following command.

chmod 750 /etc/init.d/db_start_stop

chkconfig --add db_start_stop

No comments: