ORACLE自动启动方法

 

        前段时间整理的linux下ORACLE自动启动的方法,今天回顾一下:

 

1.    Root用户登录,vi /etc/oratab 
        orcl:/u01/app/oracle/product/10.2.0/db_1:N 改为orcl:/u01/app/oracle/product/10.2.0/db_1:Y

 
 

--------------------------------------------------------------------------------------------------
2.    root 用户 在/etc/rc.d/init.d/目录下新建一个文件 oracle10g,把如下内容放到这个文件里,注意参数需要修改
[root@rhel5 ~]# cd /etc/rc.d/init.d/ 
[root@rhel5 init.d]# touch oracle10g 
[root@rhel5 init.d]# chmod a+x oracle10g 
[root@rhel5 init.d]# vim oracle10g 

 
 
 
 

#!/bin/bash
# chkconfig: 345 99 10
# description: Startup Script for Oracle Databases
# /etc/rc.d/init.d/oracle10g
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_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: can not 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
echo -n "Starting oracle10g: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/subsys/oracle10g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl start"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
echo "OK"
;;
'stop')

 

# Oracle listener and instance shutdown
echo -n "shutting down oracle10g: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl stop"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/oracle10g
echo "OK"
;;
'reload|restart')
$0 stop
$0 start
;;
*)
echo "Usage:'basename $0' start|stop|restart|reload"
exit 1
esac
exit 0

 
 

-----------------------------------------------------------------------------------------------------
3.使用oracle用户修改$ORACLE_HOME/bin/dbstart文件:

 

# su - oracle

 

$ cd $ORACLE_HOME/bin

 

$ gedit dbstart

 

找到 ORACLE_HOME_LISTNER=.....这行, 修改成

 

ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.2.0/db_1

 

或者直接修改成:

 

ORACLE_HOME_LISTNER=$ORACLE_HOME

 

注意:是修改,不是增加,可是使用gedit的查找功能查找:

 

确保执行dbstart命令没有错误,如果不修改上面的路径,dbstart会报错

 
 

--------------------------------------------------------------------------------------------------------

 

4.ROOT用户编辑 /etc/rc.d/rc.local 文件,目前我这边保留的是如下:

 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

 

touch /var/lock/subsys/local
su - oracle -lc "/u01/app/oracle/product/10.2.0/db_1/bin/lsnrctl start"
su - oracle -lc "/u01/app/oracle/product/10.2.0/db_1/bin/dbstart"

 
 
 

重启操作系统,就可以自动启动了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值