How to automatically start Oracle over 10 Gb instance databases when Linux is started:
# Description: start or stop oracle
./Etc/rc. d/init. d/functions
# Oracle_env
Export ORACLE_BASE =/u01/app/oracle/db10g
Export ORACLE_HOME = $ ORACLE_BASE/db10g
Export PATH = $ PATH: $ ORACLE_HOME/bin
Export ORACLE_SID = twerp
Oracle_user = oracle
# Killproc
Start (){
Echo-n "starting oracle :"
Su-"$ oracle_user" <EOO
Lsnrctl start
Sqlplus/nolog <EOS
Connect/as sysdba
Startup
EOS
# Exchange ORACLE_SID
Export ORACLE_SID = twwh
Sqlplus/nolog <EOS
Connect/as sysdba
Startup
EOS
EOO
}
Stop (){
Echo-n "stoping oracle :"
Su-"$ oracle_user" <EOO
Lsnrctl stop
Sqlplus/nolog <EOS
Connect/as sysdba
Shutdown immediate
EOS
# Exchange ORACLE_SID
Export ORACLE_SID = twwh
Sqlplus/nolog <EOS
Connect/as sysdba
Shutdown immediate
EOS
EOO
}
Case "$1" in
Start)
Start
Touch/var/lock/subsys/orad
;;
Stop)
Stop
Rm-f/var/lock/subsys/orad
;;
Status)
Status oracle
;;
Restart)
Stop
Sleep 3
Start
;;
*)
Echo "$0 {start | stop | status | restart }"
;;
Esac
Run the script cp to the/etc/rc. d/init. d/directory.
Add executable permissions:
Chmod 755/etc/rc. d/init. d/orad
Release:
Chkconfig -- add orad
Or use chmod a + x ora9 to add the script to the system so that it can be started and run. Run the following command:
Chkconfig -- level 3 (or 5) -- add ora9