centos上oracle 开机自启

  1. 设置oracle开机自动启动修改/etc/oratab
    vi /etc/oratab
     找到#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:修改为
    orcl:/oracle/product/11.2.0/db_1:Y
     
  2. 创建文件/etc/init.d/sail
    #!/bin/sh
    # chkconfig: 35 80 10
    # description: Oracle auto start-stop script.
    
    #
    # Set ORA_HOME to be equivalent to the $ORACLE_HOME
    # from which you wish to execute dbstart and dbshut;
    #
    # Set ORA_OWNER to the user id of the owner of the
    # Oracle database in ORA_HOME.
    ORA_HOME=/oracle/product/11.2.0/db_1
    ORA_OWNER=oracle
    if [ ! -f $ORA_HOME/bin/dbstart ]
    then
        echo "Oracle startup: cannot start"
        exit
    fi
    case "$1" in
    'start')
    # Start the Oracle databases:
    echo "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 - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
    echo "Done"
    
    # Start the Listener:
    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 - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
    echo "Done."
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Finished." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    touch /var/lock/subsys/oracle
    ;;
    
    'stop')
    # Stop the Oracle Listener:
    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 - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
    echo "Done."
    rm -f /var/lock/subsys/oracle
    
    # Stop the Oracle Database:
    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 - $ORA_OWNER -c "$ORA_HOME/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')
    $0 stop
    $0 start
    ;;
    esac
     
  3. 带有tomcat的启动脚本
    #!/bin/sh
    # chkconfig: 35 80 10
    # description: Oracle auto start-stop script.
    
    #
    # Set ORA_HOME to be equivalent to the $ORACLE_HOME
    # from which you wish to execute dbstart and dbshut;
    #
    # Set ORA_OWNER to the user id of the owner of the
    # Oracle database in ORA_HOME.
    ORA_HOME=/oracle/product/11.2.0/db_1
    ORA_OWNER=oracle
    if [ ! -f $ORA_HOME/bin/dbstart ]
    then
        echo "Oracle startup: cannot start"
        exit
    fi
    case "$1" in
    'start')
    # Start the Oracle databases:
    echo "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 - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
    echo "Done"
    
    # Start the Listener:
    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 - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
    echo "Done."
    
    # Start the tomcat:
    echo "Starting tomcat ..."
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Starting Tomcat as part of system up." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    /bin/sh /opt/sail/bin/startup.sh
    echo "Done."
    
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Finished." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    touch /var/lock/subsys/oracle
    ;;
    
    'stop')
    # Stop the tomcat :
    echo "Stoping Tomcat ..."
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Stoping Tomcat as part of system down." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    /bin/sh /opt/sail/bin/shutdown.sh
    echo "Down."
    
    # Stop the Oracle Listener:
    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 - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
    echo "Done."
    rm -f /var/lock/subsys/oracle
    
    # Stop the Oracle Database:
    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 - $ORA_OWNER -c "$ORA_HOME/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')
    $0 stop
    $0 start
    ;;
    esac
     
  4. chmod 755 /etc/init.d/sail
     
  5. chkconfig --add sail
     
    chkconfig sail on
     
  6. 命令行下启动
    service sail start
     
  7. 关闭
    service sail stop
     

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值