Home > Database > Mysql Tutorial > body text

Linux上Oracle自动启停方案

WBOY
Release: 2016-06-07 17:30:32
Original
1053 people have browsed it

Oracle在$ORACLE_HOME/bin目录下提供了dbstart和dbshut两个脚本来启动和停止Oracle。dbstart脚本将启动指定的数据库实例和Listen

环境

CentOS 6 x86_64, Oracle 11g R2

方案

Oracle在$ORACLE_HOME/bin目录下提供了dbstart和dbshut两个脚本来启动和停止Oracle。dbstart脚本将启动指定的数据库实例和Listener。

首先,修改/etc/oratab,,把要自动启动的实例对应的启动标志设置为"Y"。

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

然后,创建/etc/init.d/dbora脚本,内容如下:

#!/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 the

# 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


给dbora添加执行权限:

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

将dbora添加到自启动服务:

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

这样就可以将Oracle作为系统服务自动启停了。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!