oracle 自启,oracle数据库开机自启

登录系统后,切换到oracle用户,查看oracle_home是否设置[oracle@localhost ~]$ echo $ORACLE_HOME

/u01/app/oracle

如果查询的结果是空的话,需要编辑/home/oracle/.bash_profile[oracle@localhost ~]$ vim /home/oracle/.bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

ORACLE_BASE=/u01/app

ORACLE_HOME=$ORACLE_BASE/oracle

ORACLE_SID=hfdpc; export ORACLE_SID

PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH LANG

oracle_home的路径可以在 /etc/oratab下面看

c4f1727f1341d74a9bbe0e7febcd97ac.png

修改好oracle_home的设置后,需要使脚本生效,[oracle@localhost ~]$ source /home/oracle/.bash_profile

2.修改/etc/oratab 的配置,需要切换到root用户[root@localhost ~]$ cat /etc/oratab

hfdpc:/u01/app/oracle:N

把上面的"N"修改成"Y"[root@localhost ~]$ cat /etc/oratab

hfdpc:/u01/app/oracle:Y

3.编辑启动脚本/etc/rc.d/rc.local,添加数据库启动脚本dbstart和监听启动脚本,需要切换到root用户进行操作[root@localhost ~]$ cat /etc/rc.d/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

在脚本里面加上oracle自带的启动脚本dbstart和监听启动脚本,编辑好后保存[root@localhost ~]$ cat /etc/rc.d/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

su oracle -lc "/u01/app/oracle/bin/lsnrctl start"

su oracle -lc /u01/app/oracle/bin/dbstart

4.切换到oracle用户,在$ORACLE_HOME/bin路径下,执行dbstart[root@localhost ~]# su - oracle

[oracle@localhost ~]$ cd /u01/app/oracle/bin/

[oracle@localhost bin]$ dbstart

*在$ORACLE_HOME/bin下执行dbstart,报错“Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr“。原因是dbstart调用的tnslsnr脚本位置有错。

解决的方法是:编辑$ORACLE_HOME/bin/dbstart,

查找“ORACLE_HOME_LISTENER”变量的定义处,

修改“ORACLE_HOME_LISTENER=/ade/vikrkuma_new/oracle”为“ORACLE_HOME_LISTENER=$ORACLE_HOME”

wKioL1a***vDZ93nAAS2cI_8UNU783.jpg

5.重启数据库,查看数据库和监听是否启动

947a76c7b55e6f9dae6f1f9c22a9d42e.png

a3640432aaf73bed506c2991b69147f3.png

6.查看数据库是否处于open,保证数据库可用

c42c0bcf0eaba08f41775b50b47271bd.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值