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