ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle 11g之instance自动启动设置

oracle 11g之instance自动启动设置

原创 Linux操作系统 作者:liqilin0429 时间:2011-01-18 10:08:57 0 删除 编辑

Linux redhat 5下Oracle11g 自动随系统启动
Oracle 11g 安装完每次都得手动启动和停止数据库(dbstart or dbshut),监听器(lsnrctl),控制台(emtcl)。 
第一步:进入ORACLE_HOME/bin下修改dbstart
[root@oracle bin]# vi dbstart
# First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$1      
#此处将 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
  echo "Usage: $0 ORACLE_HOME"
else
  LOG=$ORACLE_HOME_LISTNER/listener.log

第二步:进入ORACLE_HOME/bin下修改dbshut
[root@oracle bin]# vi dbshut
# The  this to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$1
#此处将 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
  echo "Usage: $0 ORACLE_HOME"
else
  LOG=$ORACLE_HOME_LISTNER/listener.log

第三步:在 /etc/init.d 下新建一个文件
[root@oracle ~]# cd /etc/init.d
[root@oracle init.d]# vi oracle
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g AutoRun Services
# creator :qilin
# function:starts the oracle dabase deamons
# usage:startup oracle database
# last modify: qilin 2010-10-13
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/OraHome
export ORACLE_SID=pridata
export ORACLE_OWNER=oracle
export ORACLE_TERM=vt100
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
     echo "Oracle startup: cannot start"
     exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
 start)
     # Oracle listener and instance startup
     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
     echo "Oracle Start Succesful!OK."
     ;;
 stop)
     # Oracle listener and instance shutdown
     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
     echo "Oracle Stop Succesful!OK."
     ;;
 reload|restart)
     $0 stop
     $0 start
     ;;
 *)
     echo $"Usage: `basename $0` {start|stop|reload|reload}"
     exit 1
esac
exit 0

第四步:赋予执行权限
[root@oracle init.d]# chmod 750 /etc/init.d/oracle

第五步:链接
[root@oracle init.d]# ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle
[root@oracle init.d]# ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
执行以下命令:

第六步:添加到服务
[root@oracle init.d]# chkconfig --add oracle         # 添加到服务里
[root@oracle init.d]# /sbin/chkconfig --list oracle  # 查看添加的服务

第七步:修改/etc/oratab

修改/etc/oratab将所需启动的实例修改为Y
pridata:/opt/oracle/product/OraHome:Y


 

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

上一篇: oracle之Statistics
请登录后发表评论 登录
全部评论

注册时间:2010-08-13

  • 博文量
    100
  • 访问量
    227375