小工具知识网

当前位置: 首页 > 行业知识 > oracle配置开机自启动

行业知识

oracle配置开机自启动

2026-11-16 04:24:14 来源:互联网转载

Oracle在$ORACLE_HOME/bin下提供许多对数据库进行操作的脚本,其中dbstart和dbshut可分别用来启动和关闭数据库。注意,这两个脚本已包含监听器的启动或关闭,但并未对EM进行相关的操作。使用如下命令:

()
/oracle/product/11.2.0/db_1/bin/dbstart /oracle/product/11.2.0/db_1 #启动数据库实例(包含监听器)/oracle/product/11.2.0/db_1/bin/dbshut /oracle/product/11.2.0/db_1 #关闭数据库实例(包括监听器)
orcl:/oracle/product/11.2.0/db_1:Y #默认为orcl:/oracle/product/11.2.0/db_1:N

这时候用命令启动会报ORACLE_HOME_LISTNER没有设置

()
[oracle@primary bin]$  /oracle/product/11.2.0/db_1/bin/dbstart  /oracle/product/11.2.0/db_1ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener

修改dbstart和dbshut

dbstart修改前

# First argument is used to bring up Oracle Net ListenerORACLE_HOME_LISTNER=if [ ! $ORACLE_HOME_LISTNER ] ; then  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"  echo "Usage: 
# First argument is used to bring up Oracle Net ListenerORACLE_HOME_LISTNER=/u01/app/oracle/product/11.2.0/db_1                                     // --/u01/app/oracle/product/11.2.0/db_1为$ORACLE_HOMEif [ ! $ORACLE_HOME_LISTNER ] ; then  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"  echo "Usage: 
[root@oracle ~]# cd /etc/init.d
ORACLE_HOME"else LOG=$ORACLE_HOME_LISTNER/listener.log
ORACLE_HOME"else LOG=$ORACLE_HOME_LISTNER/listener.log

dbstart修改后

   使用 vi 命令,新建一个以 oracle 命名的文件(并将以下代码复制至文件中)

同理dbshut也做相应修改

在启动了Linux系统之后,转到 /etc/init.d 目录下;

[root@oracle init.d]# vi oracle  #!/bin/sh# chkconfig: 345 61 61# description: Oracle 11g AutoRun Services# /etc/init.d/oracle## Run-level Startup script for the Oracle Instance, Listener, and# Web Interface export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1export ORACLE_SID=ddhldataexport PATH=$ORACLE_HOME/bin:$PATH ORA_OWNR="oracle" # if the executables do not exist -- display error if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]then     echo "Oracle startup: cannot start"     exit 1fi # depending on parameter -- startup, shutdown, restart# of the instance and listener or usage display case "" in start)     # Oracle listener and instance startup     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart     echo "Oracle Start Succesful!OK."     ;; stop)     # Oracle listener and instance shutdown     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut     echo "Oracle Stop Succesful!OK."     ;; reload|restart)     
[root@oracle init.d]# chmod 750 /etc/init.d/oracle
stop
[root@oracle init.d]# ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle [root@oracle init.d]# ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
start ;; *) echo $"Usage: `basename
[root@oracle init.d]# chkconfig --level 345 oracle on [root@oracle init.d]# chkconfig --add oracle         //添加到服务里
` {start|stop|reload|reload}" exit 1esacexit 0

在编辑完成之后,使用 :x 命令保存此文件。

赋予执行权限

做一个链接:

执行以下命令:

上一篇:怎么删除云服务器的应用?

下一篇:物联网服务器放在哪里?