oracle 18c centos7 设置开机自动启动Oracle

学习自:

http://blog.csdn.net/condywl/article/details/57129696

1. 在root用户下进行修改 配置文件 /etc/oratab

vim /etc/oratab

内容:
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/u01/app/oracle/product/18.1.0/dbhome_1:Y

根据信息 增加后者是修改的一行信息为:

orcl:/u01/app/oracle/product/18.1.0/dbhome_1:Y

2. 切换到oracle用户,并且进入到oracle的home路径下

su - oracle
cd $ORACLE_HOME/bin

3. 编辑oracle home目录下的dbstart 以及 dbshut的文件

主要修改点:

将多个 $1 修改为 $ORACLE_HOME

以及将 ORACLEBASEHOME_EXEC修改为如下.

ORABASEHOME_EXEC=$ORACLE_HOME/bin

在bin目录下执行操作测试 

./dbshut 以及 ./dbstart 验证 能够正常开启或者关闭数据库

验证lsnrctl 下status以及 oracle  sqlplus / as sysdba 下面都可用

4. 修改开机启动脚本.

切换到root用户

su - root 

vim /etc/rc.d/rc.local
#这里需要给rc.local增加可执行权限
chmod +x /etc/rc.d/rc.local
systemd 之后 linux 应该已经不主要支持rc.local下面的启动方式了.

在文档的最后增加一行

su - oracle -lc dbstart

5. reboot linux 验证 oracle可以自动启动起来.

原文地址:https://www.cnblogs.com/jinanxiaolaohu/p/8529070.html