登录系统后,切换到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

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐