automatic startup and shutdown for oracle database in Linux April 18, 2007
Posted by Tyo in Linux, Oracle.trackback
copy this code to a file with .sh extension then move the file to your /etc/init.d then create link in your rc5.d and rc3.d so that your oracle can start and shutdown automatically when you starting up and shutdown your Linux OS. below is the script :
========= Script Begin ===================
# chkconfig: 35 95 1
# description: init script to start/stop oracle database 10g, TNS listener, EMS
#
#
# match these values to your environment:
export ORACLE_BASE=/usr/u01/app/oracle
export ORACLE_HOME=/usr/u01/app/oracle/product/10.2.0.1
export ORACLE_TERM=xterm
export PATH=/home/oracle/bin:$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
export DISPLAY=<your ip address>:0
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
su – “$ORACLE_USER”<<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
EOO
;;
stop)
su – “$ORACLE_USER”<<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
EOO
;;
*)
echo “Usage: $0 {start|stop}”
;;
esac
======= script end ==================
hope it will be useful
Hi,
When i start the DB server some of the oracle service are not getting started, i want every thing need to be start automatically.
Thanking you in advance
what exactly the service do you want to start ?
on this script i’m only add service such as emctl for web-based oracle database administration. but basically what i want to start automatic is listener, and oracle database. just don’t forget this script only works using root login, and can be use like below(manual) :
service start –> to start the database
service stop –> to stop the database
thank you
Can a second listener start up automatically (Two at a time ) while the first one was running smoothly in a 10g environment ?
=> haven’t try it before, but i think if use the lsnrctl start, every listener will be start. or perhaps it can be call using the listener name i’m still not so sure. if you have try it. please let me know.
thanks
lsnrctl start is only starting to default listener that you have. I read my preparation book the format to starting the listener is
lsnrctl start so if you not mention the listener name it means it only starting the default listener. if you have more than one and want to start or stop together in the script try to add :
== start listener =========
lsnrctl start
=====================
== stop listener ========
lsnrctl stop
=====================
after the lsnrctl start command.
hope that will help.
thanks.
Hi there,
I am new in Oracle and I am using the scritp stated above to start my database automatically at boot time. I was watching the boot process and when it tries to execute the script comes up with user oracle not found and nothing starts,
Have you seen this before?
thanks,
javier2893
I think the problem is because, when you install oracle on linux you are using different string for “$ORACLE_USER”. the standard user for installing user is oracle. if not the same then try to export ORACLE_USER =
thank you
Hi sulistyoas,
Actually I am using the same user=oracle.
If I try to run the commnad in the OS this is the error I get:
./dbora: line 44: stop}: command not found
any ideas?
Thanks,
try to remove this part :
*)
echo “Usage: $0 {start|stop}”
;;
thanks
Thanks, after removing the:
*)
echo “Usage: $0 {start|stop}”
;;
it worked.
I think, we can muliple database on solaris or linux but lisntner can be one for all database.
all that is wrong
change the parameter in /etc/oratab
change the Y for a N at the end of the line
yes, we can use oratab, somehow oratab not include shutdown mechanism when we shutdown the machine which is sometimes can gives problem on startup the database. CMIIW, thank you