How to configure Oracle Database to automatically start with server in Linux/Unix

Source: Internet
Author: User

The Oracle Database software provides the following two scripts to configure automatic Database startup and shutdown with the server:
[Oracle @ prod bin] $ pwd
/U01/app/oracle/product/11.2.0/db_1/bin
[Oracle @ prod bin] $ ls-l dbs *
-Rwxr-x --- 1 oracle oinstall 6030 Jan 1 2000 dbshut
-Rwxr-x --- 1 oracle oinstall 13797 Jan 1 2000 dbstart
 

We need to call these two scripts in the unix startup/shutdown script (rc0.d/rc1.d, etc.)
 
1. Check the oratab file under/etc/oratab. The file should contain the entries of the database to be set to auto start and close,
The autostart value is Y, as shown below:
$ ORACLE_SID: $ ORACLE_HOME: Y
 
[Oracle @ prod bin] $ more/etc/oratab
Prod:/u01/app/oracle/product/11.2.0/db_1: N
 
[Oracle @ prod bin] $ vi/etc/oratab
Prod:/u01/app/oracle/product/11.2.0/db_1: Y
 
2. Save the following file to/etc/init. d/(/etc/init. d/is unique in RedHat linux ).
 
[Root @ prod init. d] # pwd
/Etc/init. d
[Root @ prod init. d] # ls-l dbora
-Rw-r -- 1 root 1049 Mar 27 :10 dbora
 

-- Note the setting of ORA_OWNER and ORA_HOME variables.
 
---------------- Start dbora ---------------------------------
 
#! /Bin/bash
#
# Description: Oracle auto start-stop script.
#
# Chkconfig: 2345 99 10
#
# Processname: oracle
# Config:/etc/oratab
# Pidfile:/var/run/oracle. pid
 
# Source function library.
./Etc/init. d/functions
 
RETVAL = 0
ORA_OWNER = "oracle"
ORA_HOME = "/u01/app/oracle/product/11.2.0/db_1"
 
# See how we were called.
 
Prog = "oracle"
 
Start (){
Echo-n $ "Starting $ prog :"
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/dbstart"
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/lsnrctl start"
RETVAL =$?
Echo
[$ RETVAL-eq 0] & touch/var/lock/subsys/dbora
 
Return $ RETVAL
}
 
Stop (){
Echo-n $ "Stopping $ prog :"
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/dbshut"
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/lsnrctl stop"
RETVAL =$?
Echo
[$ RETVAL-eq 0] & rm-r/var/lock/subsys/dbora
 
Return $ RETVAL
}
 
Restart (){
Stop
Start
}
 
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Restart)
Restart
;;
*)
Echo $ "Usage: $0 {start | stop | restart }"
Exit 1
Esac
 
Exit $?
 
------------------ End dbora ---------------------------------

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.