目标:在centos 6.4下让oracle开机启动
方案:首先添加 启动,关闭,重启oracle的服务和实例的服务;然后把这个服务添加到系统服务的运行级别。
设置centos下开机自动启动oracle
步骤:
1,新增service
执行命令:
# vi /etc/rc.d/init.d/oracle
oracle文件的内容为:
#! /bin/bash
# chkconfig: 234 61 61
# description: oracle 11g autorun service
# /etc/rc.d/init.d/oracle
case $1 in
start)
# starts oracle listener and instance
echo starting oracle database:
su - oracle -lc lsnrctl start
su - oracle -lc dbstartup
;;
stop)
# shutdown oracle listner and instance
echo shuting down oracle database:
su - oracle -lc lsnrctl stop
su - oracle -lc dbshutdown
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo usage: {start|stop|reload|restart}
exit 1
esac
exit 0
注意:脚本中添加至少两行注释行(第3步中),,第一行告诉chkconfig该服务的运行级别;第二行添加关于服务的简要说明。
以上脚本中涉及到的两个脚本:dbstart和dbshut
2,编辑dbstartup和dbshutdown
执行命令
$ vi $oracle_home/bin/dbstartup
内容为:
#dbstartup
#/opt/oracle/102/bin
sqlplus / as sysdba startup
exit
eof
vi$oracle_home/bin/dbshutdown
内容为:
#dbshutdown
#/home/oracle/102/bin
sqlplus / as sysdba shutdown immediate
exit
eof
3,检查启动脚本是否正确
# cd /etc/rc.d/init.d
# ./oracle start
# ./oracle stop
4,把建立好的oracle服务添加到系统级别
执行如下命令:
# chmod 750 /etc/rc.d/init.d/oracle
# chkconfig --level 234 oracle on
# chkconfig --add oracle
本文永久更新链接地址: