1. 方法簡介:數據庫
使用systemd 來進行 oracle數據庫的啓動和關閉操做. 使用的腳本爲 lsnrctl和dbstartvim
2. 修改事項.bash
須要先修改一下 oracle 的啓動腳本配置:oracle
vim /etc/oratab 將裏面 最後一句話設置從N 修改成Y 容許啓動 ORA19C:/opt/oracle/product/19c/dbhome_1:Y
注意這個文檔說明:ide
# 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
而後設置這個文件的讀寫權限spa
chmod 777 /usr/bin/oracle.sh
4. 設置一個 oracle19c.servicecode
vim /etc/systemd/system/oracle19c.service
編輯添加內容爲:
[Unit]
Description=Oracle19c
After=syslog.target network.targetorm
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=oneshot
RemainAfterExit=yes
User=oracle
Environment="ORACLE_HOME=/opt/oracle/product/19c/dbhome_1"
ExecStart=/usr/bin/oracle.shblog
[Install]
WantedBy=multi-user.target
5. 設置開機自動啓動
systemctl enable oracle19c
6. 重啓測試.
成功.