Debian 6 sets Oracle 11g R2 to automatically start upon startup
Log On with the root account.
Step 1: Modify/etc/oratab
Orcl:/home/oracle/product/11.2.0/db_1: Y
Where
Orcl: sid
/Home/oracle/product/11.2.0/db_1: db_home
Y: Start Y (yes) or N (no). The default value is N, which is changed to Y.
Step 2: Create an oracle file under the/etc/init. d directory
#! /Bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# Chkconfig: 345 91 19
# Description: Startup/Shutdown Oracle listener and instance
ORA_HOME = "/home/oracle/product/11.2.0/db_1"
ORA_OWNR = "oracle"
# If the executables do not exist -- display error
If [! -F $ ORA_HOME/bin/dbstart-o! -D $ ORA_HOME]
Then
Echo "Oracle startup: cannot start"
Exit 1
Fi
# Depending on parameter -- startup, shutdown, restart
# Of the instance and listener or usage display
Case "$1" in
Start)
# Oracle listener and instance startup
Echo-n "Starting Oracle :"
Su-$ ORA_OWNR-c "$ ORA_HOME/bin/dbstart $ ORA_HOME"
Su-$ ORA_OWNR-c "$ ORA_HOME/bin/lsnrctl start"
# Optional: for Enterprise Manager software only
Su-$ ORA_OWNR-c "$ ORA_HOME/bin/emctl start dbconsole"
Touch/var/lock/oracle
Echo "OK"
;;
Stop)
# Oracle listener and instance shutdown
Echo-n "Shutdown Oracle :"
# Optional: for Enterprise Manager software only
Su-$ ORA_OWNR-c "$ ORA_HOME/bin/emctl stop dbconsole"
Su-$ ORA_OWNR-c "$ ORA_HOME/bin/lsnrctl stop"
Su-$ ORA_OWNR-c "$ ORA_HOME/bin/dbshut $ ORA_HOME"
Rm-f/var/lock/oracle
Echo "OK"
;;
Reload | restart)
$0 stop
$0 start
;;
*)
Echo "Usage: $0 start | stop | restart | reload"
Exit 1
Esac
Exit 0
Note: Modify the oracle home Directory.
/Home/oracle/product/11.2.0/db_1
And change the file permissions:
Chmod 755/etc/init. d/oracle
Step 3: Let the oracle file be called at system startup
Update-rc.d oracle ults 99 01
When performing this step, the system prompts a warning:
Insserv: warning: script 'oracle 'missing LSB tags and overrides
Restart the instance and execute lsnrctl status to find that the instance has been started. Open Toad and click OK. These errors are ignored for the moment.