CentOS 6.4下让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 <<EOF
startup
exit
EOF
vi$ORACLE_HOME/bin/dbshutdown
内容为:
#dbshutdown
#/home/oracle/102/bin
sqlplus / as sysdba <<EOF
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 2345 oracle on
# chkconfig --add oracle
Recent Comments