Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Auto start

156 views

Published on

  • Be the first to comment

  • Be the first to like this

Auto start

  1. 1. 11g R2 (11.2.0.2) -- Script to Auto Start/Shutdown databases during reboots.I have a standalone 11 R2 (11.2.0.2) non-ASM database. The following is my script which can auto start/stop database and listener duringsystem reboots. Please note that script reads /etc/oratab file to check which database to start. During startups, any database entry which hasthe "Y" at the end in the /etc/oratab file, will be started and anything which ends with "N", will be skipped.Step 1:Login as root and create a file called /etc/init.d/oracle. Add the following lines in the script.#!/bin/bash######################################################################### Run-level Startup script for the Oracle Instance and Listener## chkconfig: 345 98 34# description: Startup/Shutdown script for 11g Oracle instances################################################################################################################################################# Note:# cp $ORACLE_HOME/bin/dbstart $ORACLE_HOME/bin/dbstart.orig# Make the following changes in $ORACLE_HOME/bin/dbstart## Line#80 has the following:# ORACLE_HOME_LISTNER=$1## Replace it with the following two lines:# export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1# ORACLE_HOME_LISTNER=$ORACLE_HOME## cp $ORACLE_HOME/bin/dbshut $ORACLE_HOME/bin/dbshut.orig# Make the following changes in $ORACLE_HOME/bin/dbshut## Line#50 has the following:# ORACLE_HOME_LISTNER=$1## Replace it with the following two lines:# export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1# ORACLE_HOME_LISTNER=$ORACLE_HOME
  2. 2. ## save the file and proceed with the steps below################################################################################################################################################Instructions to start start isntances manually## To Start --> /etc/init.d/oracle start# To Stop --> /etc/init.d/oracle stop# To restrart --> /etc/init.d/oracle restart########################################################################ORA_HM="/u01/app/oracle/product/11.2.0/db_1"ORA_OWNR="oracle"# if the executables do not exist -- display errorif [ ! -f $ORA_HM/bin/dbstart -o ! -d $ORA_HM ]thenecho "Oracle startup: cannot start"exit 1fi# depending on parameter -- startup, shutdown, restart# of the instance and listener or usage displaycase "$1" instart)# starting Oracle instancesecho -n "starting Oracle Instances"su - $ORA_OWNR -c $ORA_HM/bin/dbstarttouch /var/lock/subsys/oracleps -ef |grep pmon |grep -v grepps -ef |grep lsnr |grep -v grepecho "OK";;stop)# Oracle listener and instance shutdownsu - $ORA_OWNR -c $ORA_HM/bin/dbshutrm -f /var/lock/subsys/oracle
  3. 3. ps -ef |grep pmon |grep -v grepps -ef |grep lsnr |grep -v grepecho "OK";;reload|restart)$0 stop$0 startps -ef |grep pmon |grep -v grepps -ef |grep lsnr |grep -v grepecho "OK";;*)echo "Usage: $0 start|stop|restart|reload"exit 1esacexit 0clear###################### END of SCRIPT ##############################Step-2:Change the permission of the scriptchmod 750 /etc/init.d/oracleStep-3:Execute the following so that runlevel 3,4 & 5 will execute the script during system reboots.chkconfig --level 345 oracle onStep-4Execute the script and verify everything is working as expected. Alternatively, you candownload the script directory from here.Additionally you can turn on and turn on with the following.[root@bl-mm-db-dev ~]# /sbin/chkconfig oracle off[root@bl-mm-db-dev ~]# /sbin/chkconfig --levels 345 oracle on

×