搭建完Oracle11g单实例数据库发现数据库不能开机自启解决办法

首先打开Oracle设置的一个关卡:vi /etc/oratab,修改行:

orcl:/opt/oracle/11g:Y #默认为orcl:/opt/oracle/11g:N

此处代码参考别人的的,以root身份建立开机启动oracle服务的脚本:
vi /etc/init.d/oracle,添加如下脚本:

复制代码

!/bin/sh

chkconfig: 2345 20 80

description: Oracle dbstart / dbshut

以上两行为chkconfig所需

ORA_HOME=/u01/app/oracle/product/10.2.0/db_home1 #此处根据自己的ORACLE_HHOME进行设置。
ORA_OWNER=oracle
LOGFILE=/var/log/oracle.log
echo “#################################” >> {LOGFILE}  date +”### %T %a %D: Run Oracle” >> {LOGFILE}
if [ ! -f O R A H O M E / b i n / d b s t a r t ] | | [ ! f {ORA_HOME}/bin/dbshut ]; then
echo “Error: Missing the script file O R A H O M E / b i n / d b s t a r t o r {ORA_HOME}/bin/dbshut!” >> {LOGFILE}      echo “#################################” >> {LOGFILE}
exit
fi
start(){
echo “###Startup Database…”
su - O R A O W N E R c " {ORA_HOME}/bin/dbstart {ORA_HOME}”      echo “###Done.”      echo “###Run database control…”      su - {ORA_OWNER} -c " {ORA_HOME}/bin/emctl start dbconsole”      echo “###Done.”  }  stop(){      echo “###Stop database control…”      su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole”      echo “###Done.”      echo “###Shutdown Database…”      su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}”      echo “###Done.”  }  case “ 1” in
‘start’)
start >> L O G F I L E ; ; s t o p ) s t o p >> {LOGFILE}
;;
‘restart’)
stop >> L O G F I L E s t a r t >> {LOGFILE}
;;
esac
date +”### %T %a %D: Finished.” >> {LOGFILE}  echo “#################################” >> {LOGFILE}
echo “”

接着使用如下命令将 /etc/init.d/oracle 置为可执行文件:

chmod a+x /etc/init.d/oracle
然后 reboot 重启,数据库即可开机自动启动。

猜你喜欢

转载自blog.csdn.net/qq_38264153/article/details/82730797