With Oracle 10g, Oracle switched from recommending the "su" command to the "rsh" command. In Oracle 10g release 2, the
dbstart
command includes an automatic start of the listener, so there are some differences between the two versions, but the following represents the preferred method for Oracle 10g.Once the instance is created, edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.
Next, create a file called "/etc/init.d/dbora" as the root user, containing the following.TSH1:/u01/app/oracle/product/9.2.0:Y
Use the#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! "$2" = "ORA_DB" ] ; then
if [ "$PLATFORM" = "HP-UX" ] ; then
remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
exit
fi
fi
#
case $1 in
'start')
$ORACLE_HOME/bin/dbstart $ORACLE_HOME
;;
'stop')
$ORACLE_HOME/bin/dbshut $ORACLE_HOME
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit
chmod
command to set the privileges to 750.Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.chmod 750 /etc/init.d/dbora
The relevant instances should now startup/shutdown automatically at system startup/shutdown.chkconfig --level 345 dbora on
This method relies on the presence of an RSH server, which requires additional packages and configuration.
This can be quite problematic when attempting to use this method under FC5 and FC6, where rsh is deprecated. As a result, I prefer to use the "su" command method.# Install the rhs and rsh-server packages from the OS CD/DVD.
rpm -Uvh --force rsh-*
# Enable rsh and rlogin.
chkconfig rsh on
chkconfig rlogin on
service xinetd reload
su $ORACLE $0 $1 ORA_DB
This method can also be used for 11g databases that are not using ASM or RAC.
Known Issues
When using Oracle 10g Release 2, calling
dbstart
might result in the following error message:This is due to a hard coded path in theFailed to auto-start Oracle Net Listener using /ade/vikrkuma_new/oracle/bin/tnslsnr
dbstart
script. To correct this, edit the "$ORACLE_HOME/bin/dbstart" script and replace the following line (approximately line 78):With this:ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
TheORACLE_HOME_LISTNER=$ORACLE_HOME
dbstart
script shold now start the listener as expected.For more information see:
- Automating Shutdown and Startup (10.2)
- Automating Startup and Shutdown (10.1)
- Automating Database Startup and Shutdown (9.2)
my testing result for ORHEL4
#!/bin/sh
#kconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
# set the asm device permission
chown oracle:dba /dev/hdb5
chown oracle:dba /dev/hdb6
case $1 in
'start')
su - oracle -c dbstart $ORACLE_HOME
;;
'stop')
su - oracle -c dbshut $ORACLE_HOME
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
exit