Linux下,Oracle自動啟動,停止指令碼

來源:互聯網
上載者:User
目的--- 能夠實現開機啟動Oracle--- 重啟伺服器的時候能先關閉--- Oracle可以用service命令啟、停Oracle
1. 修改Oracle系統設定檔:/etc/oratab //oratab格式:SID:ORACLE_HOME:AUTO # vi /etc/oratab orcl:/opt/app/oracle/product/10.2.0/db_1:Y
2. 在 /etc/init.d/ 下建立檔案oracle,內容如下
 
#!/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=/opt/app/oracle/product/10.2.0/db_1ORA_OWNER=oracleif [ ! -f $ORA_HOME/bin/dbstart ]then    echo "Oracle startup: cannot start"    exitficase "$1" in'start')# Start the Oracle databases:echo "Starting Oracle Databases ... " echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Starting Oracle Databasee as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oraclesu - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracleecho "Done"# Start the Listener:echo "Starting Oracle Listeners ... " echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oraclesu - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracleecho "Done."echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracletouch /var/lock/subsys/oracle;;'stop')# Stop the Oracle Listener:echo "Stoping Oracle Listeners ... " echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oraclesu - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracleecho "Done."rm -f /var/lock/subsys/oracle# Stop the Oracle Database:echo "Stoping Oracle Databases ... "echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oraclesu - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracleecho "Done."echo ""echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle;;'restart')$0 stop$0 start;;esac
3. 改變檔案許可權# chmod 755 /etc/init.d/oracle
4. 添加服務# chkconfig --level 35 oracle on
5. 需要在重新啟動時停止資料庫,做一下操作# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle  //關機# ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle  //重啟
6. 使用方法# service oracle start //啟動oracle# service oracle stop //關閉oracle
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.