Tuesday, April 8, 2008

Auto Start Oracle DB on Solaris

create a similar script in /etc/init.d


#!/bin/sh

user=oracle
SU=/bin/su
ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
export ORACLE_HOME

case "$1" in
start)
$SU $user $ORACLE_HOME/bin/dbstart
;;
restart)
$SU $user $ORACLE_HOME/bin/dbshut
$SU $user $ORACLE_HOME/bin/dbstart
;;
stop)
$SU $user $ORACLE_HOME/bin/dbshut
;;
*)
echo "Usage : oracle start restart stop"
;;
esac

Edit $ORACLE_HOME/bin/dbshut and dbstart, pay attention to where oratab is. In solaris this is in /var/opt/oracle/oratab

Create softlink on rc0 rc2 and rc3 (on solaris 10)

ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle

ln -s /etc/init.d/oracle /etc/rc2.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc2.d/S99oracle

ln -s /etc/init.d/oracle /etc/rc3.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc3.d/S99oracle