UNIX自動啟動oracle

csbin發表於2012-04-23
UNIX自動啟動oracle

1、編輯/etc/oratab,設定為Y


2、在/sbin/init.d/目錄下建立一個檔案,並命名為oracle,並授予它555許可權,更改它owner為bin:bin。

$ vi /sbin/init.d/oracle

#!/bin/sh
#
# /sbin/init.d/oracle

case "$1" in
start)
echo "Starting Oracle Databases: "
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/adm/syslog/oracle.log
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
/bin/su - oracle -c dbstart >> /var/adm/syslog/oracle.log
echo "Done."
echo "Starting Oracle Listeners: "
/bin/su - oracle -c "lsnrctl start" >> /var/adm/syslog/oracle.log
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
date +"! %T %a %D : Finished." >> /var/adm/syslog/oracle.log
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
/bin/touch /var/lock/subsys/oracle
;;
stop)
echo "Shutting Down Oracle Listeners: "
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
date +"! %T %a %D : Shutting Down Oracle Databases as part of system down."

>>/var/adm/syslog/oracle.log
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
/bin/su - oracle -c "lsnrctl stop" >> /var/adm/syslog/oracle.log
echo "Done."
rm -f /var/lock/subsys/oracle
echo "Shutting Down Oracle Databases: "
su - oracle -c dbshut >> /var/adm/syslog/oracle.log
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
date +"! %T %a %D : Finished." >> /var/adm/syslog/oracle.log
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
;;
restart)
echo "Restarting Oracle Databases: "
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
date +"! %T %a %D : Restarting Oracle Databases as part of system up." >> /var/adm/syslog/oracle.log
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
/bin/su - oracle -c dbstop >> /var/adm/syslog/oracle.log
/bin/su - oracle -c dbstart >> /var/adm/syslog/oracle.log
echo "Done."
echo "Restarting Oracle Listeners: "
/bin/su - oracle -c "lsnrctl stop" >> /var/adm/syslog/oracle.log
/bin/su - oracle -c "lsnrctl start" >> /var/adm/syslog/oracle.log
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
date +"! %T %a %D : Finished." >> /var/adm/syslog/oracle.log
echo "----------------------------------------------------" >> /var/adm/syslog/oracle.log
/bin/touch /var/lock/subsys/oracle
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac

3、建立runlevel directories下的符號連結

ln -s /sbin/init.d/oracle /sbin/rc2.d/S99orastart
ln -s /sbin/init.d/oracle /sbin/rc3.d/S99orastart
ln -s /sbin/init.d/oracle /sbin/rc0.d/K01orastop


4、測試
#/sbin/init.d/oracle start
#/sbin/init.d/oracle stop
#/sbin/init.d/oracle restart

系統啟動日誌在 /etc/rc.log

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/720091/viewspace-1057977/,如需轉載,請註明出處,否則將追究法律責任。

相關文章