oralce设置开机自启动

设置数据库监听自启动

修改/etc/oratab文件N为Y

[oracle@19c ~]$ 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/19.2.0/db_1:Y

在/etc/rc.local中添加需执行的命令

[root@19c ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local

su - oracle -c 'lsnrctl start'
su - oracle -c 'dbstart'

修改 O R A C L E H O M E / b i n / d b s t a r t 文件,修改 O R A C L E H O M E L I S T N E R = ORACLE_HOME/bin/dbstart文件,修改ORACLE_HOME_LISTNER= ORACLEHOME/bin/dbstart文件,修改ORACLEHOMELISTNER=ORACLE_HOME

[oracle@19c db_1]$ vi $ORACLE_HOME/bin/dbstart

#ORACLE_HOME_LISTNER=$1
ORACLE_HOME_LISTNER=$ORACLE_HOME

设置CentOS7,8开机执行/etc/rc.local

chmod a+x /etc/rc.d/rc.local

将 rc-local 服务设置成开机启动

systemctl enable rc-local

[root@19c ~]# systemctl status rc-local
● rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
   Active: active (exited) since Wed 2023-02-22 02:31:07 EST; 11min ago
  Process: 1025 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)

至此开机自启动完成

猜你喜欢

转载自blog.csdn.net/weixin_39735909/article/details/129163912
今日推荐