Total Pageviews

Monday 16 July 2012

How to Autostart oracle when Linux server boots up


1. Connect through root user and create the script as below at the location “/etc/init.d”
vi startup_reboot.sh and add the below lines in the script:


export ORACLE_SID=mydb
export ORACLE_BASE=/home/oracle/10.2.0/product
export ORACLE_HOME=$ORACLE_BASE/db_1
export ORA_OWNER=oracle
su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" $ORACLE_HOME
su - $ORA_OWNER -c $ORACLE_HOME/bin/dbstart $ORACLE_HOME
touch /var/lock/subsys/startup_reboot.sh

Note: Oracle Envirnment variables may change according to the entries in .bash_profile

2. Give proper permission to the root user to avoid permission errors:
chmod +x startup_reboot.sh

3. Connect through root user and create a link to run the script at the time of reboot:

ln -s /etc/init.d/startup_reboot.sh /etc/rc.d/rc5.d/S50startup_reboot.sh
The S50 is to tell the system to start the script when it boots up.

4) Update “/etc/oratab”

Connect through oracle user and Update the <N|Y> flag to “Y” for the Database Instance that need to be started up on reboot/default.The first and second fields are the system identifier and home directory of the database respectively. The third filed indicates to the dbstart utility that the database should, "Y", or should not,"N", be brought up at system boot time.

  # Entries are of the form:
              $ORACLE_SID:$ORACLE_HOME:<N|Y>
  # An example entry:
              mydb:/home/oracle/10.2.0/product/db_1:Y

 


No comments:

Post a Comment