Script to Auto Start Primary/Standby Database under Linux
The following represents the Oracle recommended method for automating database startup and shutdown of Oracle 10g instances.
Once the instance is created, edit the “/etc/oratab” file setting the restart flag for each instance to ‘Y’.
dev:/u01/app/oracle/product/10.2.0:N
Change N to Y
dev:/u01/app/oracle/product/10.2.0:Y
Next, create a file called “/etc/init.d/dbora” as the root user, containing the following.
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.ORA_HOME=/u01/app/oracle/product/10.2.0/
ORA_OWNER=oracleif [ ! -f $ORA_HOME/bin/dbstart ]
then
echo “Oracle startup: cannot start”
exit
ficase “$1” in
‘start’)
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su – $ORA_OWNER -c “$ORA_HOME/bin/dbstart $ORA_HOME”
;;
‘stop’)
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su – $ORA_OWNER -c “$ORA_HOME/bin/dbshut $ORA_HOME”
;;
esac
set the chmod command to set the privileges to 750
chmod 750 /etc/init.d/dbora
Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.
chkconfig –add dbora
The default TNS listener (LISTENER) will be started by dbshut/dbstart scripts.
If you are using customized listener name like LISTENER_TEST, LISTENER_PRE then please edit dbshut and dbstart lines as below
— At DBSHUT
$ORACLE_HOME_LISTNER/bin/lsnrctl LISTENER stop “Change to”
$ORACLE_HOME_LISTNER/bin/lsnrctl LISTENER_TEST stop–AT DBSTART
$ORACLE_HOME_LISTNER/bin/lsnrctl LISTENER start “Change to”
$ORACLE_HOME_LISTNER/bin/lsnrctl LISTENER_TEST start
The relevant instances should now startup/shutdown automatically at system startup/shutdown
Leave a Reply
You must be logged in to post a comment.