欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

Oracle服务自动启动脚本

发布时间:2025/4/16 编程问答 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Oracle服务自动启动脚本 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1.设置相应数据库实例允许用系统服务自动启动:修改oratab文件:

$ vim /etc/oratab

将sales:/u01/app/oracle/product/11.2.0/dbhome_1:N改为:sales:/u01/app/oracle/product/11.2.0/dbhome_1:Y
2. 在/etc/init.d/下创建文件oracle,内容如下:

# vim /etc/init.d/oracle #!/bin/bash #!/bin/sh #chkconfig:345 61 61 #description:Oracle self-startup script OPT_=$1 case "$OPT_" in start) /bin/echo "$0 : (start)" su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start" su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart" su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl start dbconsole" chmod 1777 /tmp chown sys:sys /tmp exit 0 ;; stop) /bin/ehco "$0 : (stop)" su -oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl stop" su -oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbshut" su -oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl stop dbconsole" exit 0 ;; *) /bin/echo '' /bin/echo "Usage: $0 [start|stop]" /bin/echo " Invalid argument ==> \"${OPT_}\"" /bin/echo '' exit 0 ;; esac

3. 改变文件权限

# chmod 755 /etc/init.d/oracle

4. 添加服务

# chkconfig --level 35 oracle on

5. 需要在关机或重启机器之前停止数据库,做一下操作

# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle //关机 # ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle //重启

6. 使用方法(适用于RHEL7)

# service oracle start //启动oracle # service oracle stop //关闭oracle # service oracle restart //重启oracle

总结

以上是生活随笔为你收集整理的Oracle服务自动启动脚本的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。