Oracle startup script

Da Emigar.
Jump to navigation Jump to search

/etc/init.d/oracle

#! /bin/sh
#
# chkconfig: 2345 29 20
# description: start Oracle RDBMS at system boot
#
### BEGIN INIT INFO
# Provides: oracle
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop:
### END INIT INFO
case "$1" in
    start)
        ORACLE_SID=
        ORAENV_ASK=NO
        export ORACLE_SID ORAENV_ASK
        . oraenv
        lsnrctl start LISTENER
        echo startup | 
	;;
    stop)
    ;;
	*)
	    echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac
exit 0


Upstart

# description "start and stop oracle instance"

start on runlevel [3]
stop on runlevel [!3]

console log
chdir /home/oracle
setuid oracle
setgid oinstall
expect fork

env ORACLE_BASE=/u01/app/oracle
env ORACLE_SID=ORCL
env ORAENV_ASK=NO

script
 . oraenv
 echo startup | sqlplus '/ as sysdba'
 lsnrctl start LISTENER
 echo 'ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;' | sqlplus '/ as sysdba'

end script

pre-stop script
 . oraenv
 echo 'ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;' | sqlplus '/ as sysdba'
 echo 'shutdown immediate' | sqlplus '/ as sysdba'
 lsnrctl stop LISTENER

end script



systemd