当前位置:  数据库>oracle

新手学堂 Linux下Oracle的自动启动及停止

    来源: 互联网  发布时间:2017-03-19

    本文导语: 1、 修改Oracle系统配置文件/etc/oratab/etc/oratab 格式为: SID:ORACLE_HOME:AUTO把AUTO域设置为Y(大写),只有这样,oracle 自带的dbstart和dbshut才能够发挥作用。我的为:ora9i:/home/oracle/ora/products/9.2.0:Y2、 编写服务脚本:如下#!/bin/bash#############...

1、 修改Oracle系统配置文件/etc/oratab
/etc/oratab 格式为: SID:ORACLE_HOME:AUTO
把AUTO域设置为Y(大写),只有这样,oracle 自带的dbstart和dbshut才能够发挥作用。我的为:
ora9i:/home/oracle/ora/products/9.2.0:Y

2、 编写服务脚本:
如下
#!/bin/bash
#
#################FUNCTION#############
#
# AutoStart Oracle and listener
# AutoStop Oracle and listener
#
#####################################
#
# Created by ZhouYS 2003-11-26
#
case "$1" in
start)
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date " %T %a %D : Starting Oracle Databasee as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "dbstart" >> /var/log/oracle
echo "Done."
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date " %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date " %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date " %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date " %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - oracle -c "dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date " %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac
将脚本命名为oracle,保存在/etc/rc.d/init.d下
改变文件属性:chmod 755 oracle
注意:在windows下编辑此文件时有DOS格式字符导致在linux下不能够正常运行,建议用gedit 或用 vi编辑

3、建立服务连接:
系统启动时启动数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc2.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc3.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc5.d/S99oracle #rc4.d unused
--------------------------------------------------------------------------------
要在重新启动时停止数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle # 停止
$ ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle # 重新启动















































































    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3