[CentOS] DB stop&start

Fri Aug 29 20:36:18 UTC 2008
David Hrbác( <hrbac.conf at seznam.cz>

Mad Unix napsal(a):
> Hi
> 
> I need  a script to automatically Starting/Stopping an Oracle 10g DB on
> CentOS5.2 64bit i.e
> lsnrctl start/stop
> db start/stop
> emctl start/stop dbconsole"
> Any help?
> 
> 

I'm using this one.
David

#!/bin/bash
#
# chkconfig: 35 95 15
# description: init script to start/stop oracle database 10g, TNS
listener, EMS
#
#
# match these values to your environment:

# Source function library.
. /etc/rc.d/init.d/functions

export ORACLE_BASE=/home/oracle
export ORACLE_HOME=/home/oracle/OraHome_1
export ORACLE_TERM=xterm
export PATH=/home/oracle/bin:/home/oracle/OraHome_1/bin:$PATH
#export NLS_LANG=''
export ORACLE_SID=orcl
export DISPLAY=localhost:0
export ORACLE_USER=oracle

prog="Oracle"

# see how we are called:

start() {
        echo -n $"Starting $prog: "
        su - "$ORACLE_USER"<<EOO
        lsnrctl start
        sqlplus /nolog<<EOS
        connect / as sysdba
        startup
EOS
        emctl start dbconsole
EOO
        touch /var/lock/subsys/ora10
}

stop() {
        echo -n $"Stopping $prog: "
        su - "$ORACLE_USER"<<EOO
        emctl stop dbconsole
        lsnrctl stop
        sqlplus /nolog<<EOS
        connect / as sysdba
        shutdown immediate
EOS
EOO
}




case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        stop
        sleep 10
        start
        ;;

*)
        echo $"Usage: $0 {start|stop}"
        exit 1

esac