Linux下oracle自动启动脚本

Linux下oracle自动启动脚本

vi /etc/oratab
SID:ORACLE_HOME:Y    #把AUTO域设置为Y(大写),只有这样,Oracle 自带的dbstart和dbshut才能够发挥作用。

自动启动脚本/etc/rc.d/init.d/oracle
case "$1" in
start)
echo "Starting Oracle Database..."
echo "-------------------------------" >> /var/log/oracle
date +"%T %a %D :Starting Oracle Database 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
touch /var/lock/subsys/oracle

;;
stop)
echo "Stoping Oracle Listener ... "
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 : Finsthed." >> /var/log/oracle
echo "------------------------------------" >> /var/log/oracle

;;
restart)
$0 stop
$0 start

;;
*)
echo "Usage: oracle { start | stop | restart } "
exit 1
esac

chmod 755 /etc/rc.d/init.d/oracle

ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc2.d/S99oracle
ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/S99oracle
ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/S99oracle

ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc0.d/K01oracle
ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc6.d/K01oracle

 

转载地址:http://fangrn.javaeye.com/blog/494088

你可能感兴趣的:(oracle,linux,脚本,database,System)