To start and stop Oracle 10g using the "wajig start|stop" commands, we need to edit the /etc/oratab file, and create the appropriate script in /etc/init.d.
First edit the /etc/oratab file. The format of this file is:
SID:ORACLE_HOME:AUTO_START
Put a Y in the AUTO_START field of the databases you want to start automagically, and a N for the ones you don't. Your file might look like this to start databases test1 and test2, and not start test3:
test1:/u01/app/oracle/product/10.1.0/db_1:Y test2:/u01/app/oracle/product/10.1.0/db_1:Y test3:/u01/app/oracle/product/10.1.0/db_1:N
Now we need to create the init.d script.
#!/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="/u01/app/oracle/product/10.1.0/db_3" 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/lsnrctl start" su - $ORA_OWNR -c $ORA_HOME/bin/dbstart touch /var/lock/subsys/oracle echo "OK" ;; stop) # Oracle listener and instance shutdown echo -n "Shutdown Oracle: " su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop" su - $ORA_OWNR -c $ORA_HOME/bin/dbshut rm -f /var/lock/subsys/oracle echo "OK" ;; reload|restart) $0 stop $0 start ;; *) echo "Usage: $0 start|stop|restart|reload" exit 1 esac exit 0
To make the script run at boot-time, and let you "wajig start|stop oracle", do the following:
ln -s /etc/init.d/oracle /etc/rc.d/rc2.d/S99oracle ln -s /etc/init.d/oracle /etc/rc.d/rc3.d/S99oracle ln -s /etc/init.d/oracle /etc/rc.d/rc4.d/S99oracle ln -s /etc/init.d/oracle /etc/rc.d/rc0.d/K01oracle ln -s /etc/init.d/oracle /etc/rc.d/rc6.d/K01oracle
Now we can start and stop oracle by:
wajig start oracle wajig stop oracle