oracle开机自动启动方法以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
以redhat 和oracle g为例 安装过程参考官方文档 以下是实现oracle自启动的方法
配置dbstart和dbshut
在$ORACLE_HOME/bin中 有dbstart和dbshut这两个脚本 more dbstart看一下可以看到
QUOTE:
#
# $Id: dbstart sh pp may : : vikrkuma Exp $
# Copyright (c) Oracle All rights reserved
#
###################################
#
# usage: dbstart
#
# This is used to start ORACLE from /etc/rc( local)
# It should ONLY be executed as part of the system boot procedure
#
# This will start all databases listed in the oratab file
# whose third field is a Y If the third field is set to Y and
# there is no ORACLE_SID for an entry (the first field is a *)
# then this will ignore that entry
#
# This requires that ASM ORACLE_SID s start with a + and
# that non ASM instance ORACLE_SID s do not start with a +
#
# If ASM instances are to be started with this it cannot
# be used inside an rc* d directory and should be invoked from
# rc local only Otherwise the CSS service may not be available
# yet and this will block init from pleting the boot
# cycle
#
# Note:
# Use ORACLE_TRACE=T for tracing this
#
# The progress log for each instance bringup plus Error and Warning message[s]
# are logged in file $ORACLE_HOME/startup log The error messages related to
# instance bringup are also logged to syslog (system log module)
# The Listener log is located at $ORACLE_HOME_LISTNER/listener log
可以看出这个脚本是用来启动oracle服务的 包括listener instance asm instances 并且可以放到/etc/rc( local) 同样dbshut也是起到关闭服务的作用
配置系统使这个脚本起作用
) 以root编辑/etc/oratab 类似 orcl:/u /product/ /db_ :N 这种格式 其中orcl是你的ORACLE_SID /u /product/ /db_ 是ORACLE_HOME 这里需要把N改为Y 即orcl:/u /product/ /db_ :Y这样
) 以oracle编辑$ORACLE_HOME/bin/dbstart 找到其中第 行:ORACLE_HOME_LISTNER=改为你自己的路径 或者可以改成ORACLE_HOME_LISTNER=$ORACLE_HOME
保存脚本 以oracle用户运行dbshut和dbstart看是否能关闭 启动数据库 如果不能 一般是参数设置 根据报错找到对应位置更改
把dbstart和dbshut加到redhat启动服务中
经过上一步的配置 可以直接用dbstart命令启动数据listener instance asm instances 但是还没有启动oracle g的EM ORACLE利用web页面管理数据库相当方便 也是 g的一个特色 所以应该一并启动起该服务来
QUOTE:
$ORACLE_HOME/bin/emctl start dbconsole
因此我们可以用rc local或者redhat服务都可以实现要求的开机启动 下面分别说一下
) 利用rc local 直接把dbstart加到rc local中 实现开机自动启动 这里需要注意的是必须以oracle启动该脚本
用root编辑/etc/rc local 添加下面一行
QUOTE:
su oracle c /u /product/ /db_ /bin/dbstart
su oracle c /u /product/ /db_ /bin/emctl start dbconsole
这里/u /product/ /db_ 需要替换成实际的ORACLE_HOME
保存并退出后 reboot服务器测试一下 可以看到 当系统启动以后oracle监听 实例和em都已经起来了
) 如果我们不用rc local 也可以加到redhat服务中 在/etc/rc d/init d中添加如下脚本文件 命名为oracle
QUOTE:
#!/bin/sh
#cconfig:
#deion: ORACLE g Server
ORACLE_HOME=/u /product/ /db_
if [ ! f $ORACLE_HOME/bin/dbstart ]
then
echo ORACLE cannot start
exit
fi
case $ in
start )
echo Starting Oracle Database
su oracle c $ORACLE_HOME/bin/dbstart
su oracle c $ORACLE_HOME/bin/emctl start dbconsole
;;
stop )
echo Stoping Oracle Database
su oracle c $ORACLE_HOME/bin/emctl stop dbconsole
su oracle c $ORACLE_HOME/bin/dbshut
;;
esac
注意其中两行注释 网上很多脚本因为少了这两行不能使服务自启动
QUOTE:
#cconfig:
#deion: ORACLE g Server
其中cconfig 是指脚本将为运行级 启动oracle g服务 启动优先级为 关闭优先级为
然后以root权限:
QUOTE:
# cd /etc/rc d
# ln s /etc/rc d/init d/oracle S oracle
# cconfig list oracle
# cconfig level on
重启系统 就可以在启动的过程中看到 Starting oracle 因为我们设置的优先级为 一般是最后启动 [OK]以后就可以了 因为要启动emctl 可能有点慢 等待的时间要稍微长一点 lishixinzhi/Article/program/Oracle/201311/16863
分页:123