歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux服務器

講解linux環境下Oracle的自動啟動與停止

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 "{GetProperty(Content)}" 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)

{GetProperty(Content)} stop

{GetProperty(Content)} start

;;

*)

echo "Usage: oracle {start|stop|restart}"

exit 1

esac
 

Copyright © Linux教程網 All Rights Reserved