1. 需要先修改一下 oracle 的启动脚本配置
[root@TradeProbe ~]# 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.
#
#
# tradeprobe:/u01/app/oracle/product/19.2.0/db_1:N
tradeprobe:/u01/app/oracle/product/19.2.0/db_1:Y
[root@TradeProbe ~]#
2. 然后设置一下 数据库的启动命令
[root@TradeProbe ~]# vim /usr/bin/oracle.sh
#! /bin/bash
# script For Oracle19c.service
/u01/app/oracle/product/19.2.0/db_1/bin/lsnrctl start
/u01/app/oracle/product/19.2.0/db_1/bin/dbstart /u01/app/oracle/product/19.2.0/db_1/
3. 然后设置这个文件的读写权限
[root@TradeProbe ~]# chmod 777 /usr/bin/oracle.sh
4. 设置一个 oracle19c.service
[root@TradeProbe ~]# 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=/u01/app/oracle/product/19.2.0/db_1"
ExecStart=/usr/bin/oracle.sh
[Install]
WantedBy=multi-user.target
查看是否设置成功
[root@TradeProbe ~]# cat /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=/u01/app/oracle/product/19.2.0/db_1"
ExecStart=/usr/bin/oracle.sh
[Install]
WantedBy=multi-user.target
[root@TradeProbe ~]#
5.设置开机自动启动
[root@TradeProbe ~]# systemctl enable oracle19c.service
Created symlink /etc/systemd/system/multi-user.target.wants/oracle19c.service → /etc/systemd/system/oracle19c.service.
[root@TradeProbe ~]#
6. 重启测试
查看Oracle服务状态
[root@TradeProbe ~]# systemctl status oracle19c.service
● oracle19c.service - Oracle19c
Loaded: loaded (/etc/systemd/system/oracle19c.service; enabled; vendor prese>
Active: activating (start) since Mon 2021-08-16 12:16:37 CST; 23s ago
Main PID: 1125 (oracle.sh)
Tasks: 40 (limit: 24886)
Memory: 1.5G
CGroup: /system.slice/oracle19c.service
├─1125 /bin/bash /usr/bin/oracle.sh
├─1278 /u01/app/oracle/product/19.2.0/db_1/bin/tnslsnr LISTENER -inh>
├─1327 /bin/sh /u01/app/oracle/product/19.2.0/db_1/bin/dbstart /u01/>
├─1437 /bin/sh /u01/app/oracle/product/19.2.0/db_1/bin/dbstart /u01/>
├─1599 sqlplus
├─2242 ora_pmon_tradeprobe
├─2244 ora_clmn_tradeprobe
├─2246 ora_psp0_tradeprobe
├─2248 ora_vktm_tradeprobe
├─2252 ora_gen0_tradeprobe
├─2256 ora_mman_tradeprobe
├─2258 ora_gen1_tradeprobe
├─2261 ora_diag_tradeprobe
├─2263 ora_ofsd_tradeprobe
├─2266 ora_dbrm_tradeprobe
├─2268 ora_vkrm_tradeprobe
[root@TradeProbe ~]#
登录em网址是否成功
使用sqlplus命令登录进行验证
[oracle@TradeProbe ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Aug 16 12:27:00 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show user
USER is "SYS"
SQL>