ITPub博客

首页 > 数据库 > Oracle > linux下添加oracle自启动脚本

linux下添加oracle自启动脚本

原创 Oracle 作者:lurou 时间:2012-05-19 12:06:14 0 删除 编辑
linux环境下oracle自动启动关闭的脚本,会经常用到。[@more@]

1.修改/etc/oratab文件,后面的dbstart和dbshut依据这个文件启动数据库

soadb:/u01/oracle/product/11.2.0/dbhome_1:Y

2.创建数据库初始化文件:

#cp $ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora.* $ORACLE_HOME/dbs/init$ORACLE_SID.ora

cp /u01/oracle/admin/soadb/pfile/init.ora.116201214406 /u01/oracle/product/11.2.0/dbhome_1/dbs/initsoadb.ora

3.接下来在/etc/init.d下建立系统自动启动和关机前自动关闭Oracle的脚本文件,分别如下:

3.1添加文件

vi start_oracle.sh

脚本内如下,拷贝过去就可以:

#!/bin/bash

#this script is used to start the oracle

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/dbstart"

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"

继续赋权:

chmod a+x /etc/init.d/start_oracle.sh

继续添加关机脚本:

vi stop_oracle.sh

脚本内容如下,也是拷贝过去即可:

#!/bin/bash

#this script is used to stop the oracle

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/lsnrctl stop"

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/dbshut"

继续赋权:

chmod a+x /etc/init.d/stop_oracle.sh

4.创建随系统启动和关闭的链接:

在/etc/rc2.d下加入自动启动链接,命令如下:

ln -s /etc/init.d/start_oracle.sh /etc/rc.d/rc2.d/S16start_oracle

ln -s /etc/init.d/start_oracle.sh /etc/rc.d/rc3.d/S16start_oracle

ln -s /etc/init.d/start_oracle.sh /etc/rc.d/rc5.d/S16start_oracle

在/etc/rc0.d下加入自动关闭链接,接着cp这两个链接在/etc/rc.d/rcN.d(N=3,5)下各一份

命令如下:

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc2.d/K01stop_oracle

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc3.d/K01stop_oracle

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc5.d/K01stop_oracle

设置完毕,可以重启看看效果了。

linux:~ # reboot

test@linux:~> ps -ef | grep ora

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26006637/viewspace-1058263/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: linux下添加磁盘
请登录后发表评论 登录
全部评论

注册时间:2011-07-01

  • 博文量
    69
  • 访问量
    259426