CentOS 7.6 RPM 方式安裝Oracle19c 后 使用 systemd 的方式設置開機自動啟動Oracle數據庫


1. 方法簡介:

使用systemd 來進行 oracle數據庫的啟動和關閉操作. 使用的腳本為 lsnrctl和dbstart

2. 修改事項.

需要先修改一下 oracle 的啟動腳本配置:

vim /etc/oratab

將里面 最后一句話設置從N 修改為Y 允許啟動

ORA19C:/opt/oracle/product/19c/dbhome_1:Y

注意這個文檔說明:

# 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.

3. 然后設置一下 數據庫的啟動命令

vim /usr/bin/oracle.sh

增加的內容為:
#! /bin/bash
#  script  For oracle19c.service
/opt/oracle/product/19c/dbhome_1/bin/lsnrctl start
/opt/oracle/product/19c/dbhome_1/bin/dbstart /opt/oracle/product/19c/dbhome_1

然后設置這個文件的讀寫權限

chmod 777 /usr/bin/oracle.sh

4. 設置一個 oracle19c.service

vim /etc/systemd/system/oracle19c.service

編輯添加內容為:

[Unit]
Description=Oracle19c
After=syslog.target network.target

[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=oneshot
RemainAfterExit=yes
User=oracle
Environment="ORACLE_HOME=/opt/oracle/product/19c/dbhome_1"
ExecStart=/usr/bin/oracle.sh

[Install]
WantedBy=multi-user.target

5. 設置開機自動啟動

systemctl enable oracle19c

6. 重啟測試.

成功. 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM