rc file for Oracle Database

This rc script is for Red Hat/CentOS/Oracle Linux systems, to start Oracle Database automatically on system startup.

$Id: rc_dbora.html,v 1.1 2010-05-28 14:43:53+09 kabe Exp $


Usage

Description

The official manual includes a sample rc script. Using that is recommended if it suffices.

This script does


kabe.sra-tohoku.co.jp
#! /bin/sh # # /etc/rc.d/init.d/dbora Oracle Database # # chkconfig: - 98 06 # description: Oracle Database + Enterprise Manager # # config: /etc/oratab # # $Id: rc_dbora.html,v 1.1 2010-05-28 14:43:53+09 kabe Exp $ . /etc/rc.d/init.d/functions # Change the value of ORACLE_HOME to specify the correct Oracle home # directory for your installation. # #ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 # # Change the value of ORACLE to the login name of the # oracle owner at your site. # #ORACLE_USER=oracle if [ -r /etc/sysconfig/dbora ]; then . /etc/sysconfig/dbora fi : ${ORACLE_USER:=oracle} : ${ORATAB:=/etc/oratab} : ${START_EM:=yes} ## reset LANG to get sane log output # system unset LANG; export LANG unset LC_ALL; export LC_ALL # Oracle : ${NLS_LANG:=English_Japan.WE8ISO8859P1} : ${NLS_DATE_FORMAT:="YYYY-MM-DD"} export NLS_LANG NLS_DATE_FORMAT # extract ORACLE_HOME from first "Y" entry in oratab, # to invoke listener in bin/dbstart if [ -z "$ORACLE_HOME" ]; then ORACLE_HOME=`awk -F: '!/^#/ && NF==3 && $3 == "Y" {print $2; exit}' $ORATAB` # emctl needs ORACLE_SID ORACLE_SID=`awk -F: '!/^#/ && NF==3 && $3 == "Y" {print $1; exit}' $ORATAB` fi if [ -z "$ORACLE_HOME" ]; then echo "ORACLE_HOME not set; abort" >&2 exit 1 fi #PATH=${PATH}:$ORACLE_HOME/bin #export ORACLE_HOME PATH sudo="" if [ x`id -un` != x"$ORACLE_USER" ]; then sudo="sudo -u $ORACLE_USER -H --" ## sudo resets environ unless -E, so you may need "env VAR=val" fi # # case $1 in 'start') echo $"Starting Oracle Database" # Processing Database instance "$ORACLE_SID": log file $ORACLE_HOME/startup.log $sudo env NLS_LANG=$NLS_LANG \ $ORACLE_HOME/bin/dbstart $ORACLE_HOME s=$? if [ $s -eq 0 ]; then touch /var/lock/subsys/dbora success $"dbora startup" else failure $"dbora startup" fi ## (should Enterprise Manager startup in different rc?) case "$START_EM" in yes|true|1) echo $"Starting Oracle Enterprise Manager" # emctl needs ORACLE_SID $sudo env NLS_LANG=$NLS_LANG ORACLE_SID=$ORACLE_SID \ $ORACLE_HOME/bin/emctl start dbconsole s=$? if [ $s -eq 0 ]; then #touch /var/lock/subsys/dbora-em success $"dbora-em startup" else failure $"dbora-em startup" fi ;; esac ;; 'stop') echo $"Stopping Oracle Database" # Processing Database instance "$ORACLE_SID": log file $ORACLE_HOME/shutdown.log $sudo env NLS_LANG=$NLS_LANG \ $ORACLE_HOME/bin/dbshut $ORACLE_HOME s=$? if [ $s -eq 0 ]; then rm -f /var/lock/subsys/dbora success $"dbora shutdown" else failure $"dbora shutdown" fi ## (should Enterprise Manager startup in different rc?) case "$START_EM" in yes|true|1) echo $"Stopping Oracle Enterprise Manager" # emctl needs ORACLE_SID $sudo env NLS_LANG=$NLS_LANG ORACLE_SID=$ORACLE_SID \ $ORACLE_HOME/bin/emctl stop dbconsole s=$? if [ $s -eq 0 ]; then success $"dbora-em shutdown" #rm -f /var/lock/subsys/dbora-em else failure $"dbora-em shutdown" fi ;; esac ;; *) echo "usage: $0 {start|stop}" exit ;; esac # exit