Set Oracle instance and listener service to start automatically
1. Add a STARTUP script
Touch/etc/init. d/orcl
Vi orcl
#! /Bin/bash
# Whoami
# Root
# Chkconfig: 345 51 49
#/Etc/init. d/orcl
# Description: starts the oracle dabase deamons
#
ORA_HOME =/home/oracle/product/10.2.0/db_1/
ORA_OWNER = oracle
Case "$1" in
Start)
Echo-n "Starting orcl :"
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/dbstart "&
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/lsnrctl start"
Touch/var/lock/subsys/orcl
Echo
;;
Stop)
Echo-n "shutting down orcl :"
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/dbshut "&
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/lsnrctl stop"
Rm-f/var/lock/subsys/orcl
Echo
;;
Restart)
Echo-n "restarting orcl :"
$0 stop
$0 start
Echo
;;
*)
Echo "Usage: 'basename $ 0' start | stop | restart"
Exit 1
Esac
Exit 0
Save orcl and exit
2. Add Configuration Service
/Sbin/chkconfig -- add orcl
3. Modify the/etc/oratab File
Vi/etc/oratab
ORACLE_SID: ORACLE_HOME: Y -- whether to enable auto-start
4. Restart and test.
Or simply add two startup commands to/etc/rc. d/rc. local.
Su-oracle-c/home/oracle/product/10.2.0/db_1/bin/dbstart
Su-oracle-c/home/oracle/product/10.2.0/db_1/bin/lsnrctl start