oracle9.2 for Redhat8 开机自启动:

oracle9.2 for Redhat8 开机自启动:
 
   1,修改Oracle系统配置文件/etc/oratab
   /etc/oratab 格式为: SID:ORACLE_HOME:AUTO
   把AUTO域设置为Y(大写),只有这样,oracle 自带的dbstart和dbshut才能够发挥作用。
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
*:/home/oracle/product/10.1:N
orcl:/home/oracle/product/10.1:Y
 
   2,编写服务脚本
     root身份登陆,将脚本命名为oracle_dbstart_redhat.sh,保存在/etc/rc.d/init.d下
     [root@localhost root]# vi /etc/rc.d/init.d/oracle_dbstart_redhat.sh
内容如下:
case "$1" in
  start)
        echo -n "Starting Oracle Databases: "
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        ##su - oracle -c /opt/ora9/product/9.2/bin/dbstart >> /var/log/oracle
        su - oracle -c /home/oracle/product/10.1/bin/dbstart >> /var/log/oracle
        echo "Done."
        echo -n "Starting Oracle Listeners: "
        ##su - oracle -c "/opt/ora9/product/9.2/bin/lsnrctl start" >> /var/log/oracle
        su - oracle -c "/home/oracle/product/10.1/bin/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 -n "Shutting Down Oracle Listeners: "
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Shutting Down Oracle Databases as part of system down." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        ##su - oracle -c "/opt/ora9/product/9.2/bin/lsnrctl stop" >> /var/log/oracle
        su - oracle -c "/home/oracle/product/10.1/bin/lsnrctl stop" >> /var/log/oracle
        echo "Done."
        rm -f /var/lock/subsys/oracle
        echo -n "Shutting Down Oracle Databases: "
        ##su - oracle -c /opt/ora9/product/9.2/bin/dbshut >> /var/log/oracle
        su - oracle -c /home/oracle/product/10.1/bin/dbshut >> /var/log/oracle
        echo "Done."
        echo ""
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Finished." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        ;;
  restart)
        echo -n "Restarting Oracle Databases: "
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Restarting Oracle Databases as part of system up." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        su - oracle -c /home/oracle/product/10.1/bin/dbshut >> /var/log/oracle
        su - oracle -c /home/oracle/product/10.1/bin/dbstart >> /var/log/oracle
        ##su - oracle -c /opt/ora9/product/9.2/bin/dbstart >> /var/log/oracle
        echo "Done."
        echo -n "Restarting Oracle Listeners: "
        ##su - oracle -c "/opt/ora9/product/9.2/bin/lsnrctl stop" >> /var/log/oracle
        ##su - oracle -c "/opt/ora9/product/9.2/bin/lsnrctl start" >> /var/log/oracle
        su - oracle -c "/home/oracle/product/10.1/bin/lsnrctl stop" >> /var/log/oracle
        su - oracle -c "/home/oracle/product/10.1/bin/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
        ;;
  *)
        echo "Usage: oracle {start|stop|restart}"
        exit 1
esac
       
保存后,改变文本属性为chmod 755 oracle


   3,建立服务连接
系统启动时启动数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
[oracle@localhost rc2.d]$ ln -s /etc/init.d/oracle_dbstart_redhat.sh /etc/rc2.d/S99oracle_dbstart_redhat
[oracle@localhost rc3.d]$ ln -s /etc/init.d/oracle_dbstart_redhat.sh /etc/rc3.d/S99oracle_dbstart_redhat
--------------------------------------------------------------------------------
要在重新启动时停止数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
[oracle@localhost rc0.d]$ ln -s /etc/init.d/oracle_dbstart_redhat.sh /etc/rc0.d/K01oracle_dbstart_redhat # 停止
[oracle@localhost rc6.d]$ ln -s /etc/init.d/oracle_dbstart_redhat.sh /etc/rc6.d/K01oracle_dbstart_redhat # 重新启动

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值