首页 > 数据库技术 > 详细

oracle数据库开机自启

时间:2016-01-13 13:11:41      阅读:412      评论:0      收藏:0      [点我收藏+]
  1. 登录系统后,切换到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下面看

技术分享

修改好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”

技术分享

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

技术分享

技术分享

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

技术分享


oracle数据库开机自启

原文:http://zhangya.blog.51cto.com/9996994/1734434

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!