设为首页 收藏本站
查看: 591|回复: 0

[经验分享] redhat as5.1下配置oracle11g自启动脚本

[复制链接]

尚未签到

发表于 2016-5-15 00:38:20 | 显示全部楼层 |阅读模式
  本文引用来至于:http://dbajun.iyunv.com/blog/247891
  

  原文章的标题“Redhat as4 下oracle10g自启动脚本设置”  经过我的验证,此文的步骤在AS5.1 oracle11g下同样适用。
  
  2011年12月22日 经验证在“Redflag AS 5.5”同样适用。
  
  以redhat as4和oracle 10g为例。单机在安装过程依照oracle官方的文档一步步下来,只要设置好参数、安装好必要的包,一般不会出什么问题。安装好了以后系统重启,oracle重启服务,网上很多人建议自己写脚本(其实脚本也很简单),这里讲的是用oracle本身的脚本实现,当然不可避免最后还要写一点点的。

1、配置dbstart和dbshut

在$ORACLE_HOME/bin中,有dbstart和dbshut这两个脚本,more dbstart看一下可以看到:
QUOTE:
#
# $Id: dbstart.sh.pp 11-may-2005.18:18:07 vikrkuma Exp $
# Copyright (c) 1991, 2005, Oracle. All rights reserved.
#

###################################
#
# usage: dbstart
#
# This script is used to start ORACLE from /etc/rc(.local).
# It should ONLY be executed as part of the system boot procedure.
#
# This script 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 script will ignore that entry.
#
# This script 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 script, 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 script will block init from completing the boot
# cycle.
#
# Note:
# Use ORACLE_TRACE=T for tracing this script.
#
# The progress log for each instance bringup plus Error and Warning message
# 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也是起到关闭服务的作用。

配置系统使这个脚本起作用:

1)、以root编辑/etc/oratab,类似 orcl:/u01/product/10.2.0/db_1:N 这种格式,其中orcl是你的ORACLE_SID,/u01/product/10.2.0/db_1是ORACLE_HOME,这里需要把N改为Y,即orcl:/u01/product/10.2.0/db_1:Y这样。

2)、以oracle编辑$ORACLE_HOME/bin/dbstart,找到其中第78行:ORACLE_HOME_LISTNER=改为你自己的路径,或者可以改成ORACLE_HOME_LISTNER=$ORACLE_HOME

保存脚本,以oracle用户运行dbshut和dbstart看是否能关闭、启动数据库。如果不能,一般是参数设置,根据报错找到对应位置更改。

2、把dbstart和dbshut加到redhat启动服务中

经过上一步的配置,可以直接用dbstart命令启动数据listener、instance、asm instances,但是还没有启动oracle10g的EM,ORACLE利用web页面管理数据库相当方便,也是10g的一个特色,所以应该一并启动起该服务来。
QUOTE:
$ORACLE_HOME/bin/emctl start dbconsole
  
因此我们可以用rc.local或者redhat服务都可以实现要求的开机启动。下面分别说一下:

1)、利用rc.local。直接把dbstart加到rc.local中,实现开机自动启动。这里需要注意的是必须以oracle启动该脚本。

用root编辑/etc/rc.local,添加下面一行:
QUOTE:
su - oracle -c "/u01/product/10.2.0/db_1/bin/dbstart"
su - oracle -c "/u01/product/10.2.0/db_1/bin/emctl start dbconsole"
  
这里/u01/product/10.2.0/db_1需要替换成实际的ORACLE_HOME

保存并退出后,reboot服务器测试一下,可以看到,当系统启动以后oracle监听、实例和em都已经起来了

2)、如果我们不用rc.local,也可以加到redhat服务中。在/etc/rc.d/init.d中添加如下脚本文件,命名为oracle:(以root用户)
QUOTE:
#!/bin/sh
#chkconfig: 2345 99 01
#description: ORACLE 10g Server

ORACLE_HOME=/u01/product/10.2.0/db_1

if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "ORACLE cannot start"
exit
fi

case "$1" 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:
#chkconfig: 2345 99 01
#description: ORACLE 10g Server
  
其中chkconfig:2345 99 01 是指脚本将为运行级2、3、4、5启动oracle 10g服务,启动优先级为99,关闭优先级为01。

然后以root权限:(要给刚才创建的oracle赋予755权限,否则服务启动不起来。)
QUOTE:
  # chmod 755 /etc/rc.d/init.d/oracle
  # cd /etc/rc2.d
# ln -s /etc/rc.d/init.d/oracle S99oracle
# chkconfig --list oracle
# chkconfig --level 2345 oracle on
  
重启系统,就可以在启动的过程中看到 Starting oracle,因为我们设置的优先级为99,一般是最后启动。[OK]以后就可以了。因为要启动emctl,可能有点慢,等待的时间要稍微长一点。

启动以后可以以root执行oracle start或者oracle stop来启动或停止服务。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-217009-1-1.html 上篇帖子: Redhat linux5.5下安装 + 配置 Oracle 10g 下篇帖子: java邮件开发(2、redhat下部署邮件服务器)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表