Oracle automatic start/stop solution on Linux

Source: Internet
Author: User
Oracle provides the dbstart and dbshut scripts in the $ ORACLE_HOMEbin directory to start and stop Oracle. The dbstart script starts the specified database instance and Listen.

Oracle provides dbstart and dbshut scripts in the $ ORACLE_HOME/bin directory to start and stop Oracle. The dbstart script starts the specified database instance and Listen.

Environment

CentOS 6 x86_64, Oracle 11g R2

Solution

Oracle provides dbstart and dbshut scripts in the $ ORACLE_HOME/bin directory to start and stop Oracle. The dbstart script starts the specified database instance and Listener.

First, modify/etc/oratab and set the startup flag of the instance to "Y ".

ORA01:/home/oracle/app/oracle/product/11.2.0/dbhome_1: Y

Then, create the/etc/init. d/dbora script with the following content:

#! /Bin/bash

### BEGIN INIT INFO

# Provides: Oracle

# Required-Start: $ local_fs $ network $ remote_fs

# Required-Stop: $ local_fs $ network $ remote_fs

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: start and stop oracle

# Description: Oracle is a damn RDBMS

### END INIT INFO

#

# Change the value of ORACLE_HOME to specify the correct Oracle home

# Directory for your installation.

ORACLE_HOME =/home/oracle/app/oracle/product/11.2.0/dbhome_1/

#

# Change the value of ORACLE_OWNER to the login name of

# Oracle owner at your site.

#

ORACLE_OWNER = "oracle"

LOCK_FILE = "/var/lock/subsys/dbora"

Case $1 in

'Start ')

Su-$ ORACLE_OWNER-c "$ ORACLE_HOME/bin/dbstart $ ORACLE_HOME &"

Touch $ LOCK_FILE

;;

'Stop ')

Su-$ ORACLE_OWNER-c "$ ORACLE_HOME/bin/dbshut $ ORACLE_HOME &"

Rm-f $ LOCK_FILE

;;

*)

Echo "usage: $0 {start | stop }"

Exit

;;

Esac

Exit


Add the execution permission to dbora:

Chmod a + x/etc/init. d/dbora

Add dbora to the self-starting service:

Chmod a + x/etc/init. d/dbora

In this way, Oracle can be automatically started and stopped as a system service.

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.