编辑 /etc/oratab 文件

修改其中的路径,并且将最后的 “N” 改为 “Y”,如下:

orcl:/home/oracle/app/oracle/product/12.2.0/dbhome_1:Y

创建/修改 /etc/systemd/system/oracle-rdbms.service 文件

文件内容如下(注意其中文件路径):

# /etc/systemd/system/oracle-rdbms.service
# Invoking Oracle scripts to start/shutdown Instances defined in /etc/oratab
# and starts Listener
[Unit]
Description=Oracle Database(s) and Listener
Requires=network.target
[Service]
Type=forking
Restart=no
ExecStart=/home/oracle/app/oracle/product/12.2.0/dbhome_1/bin/dbstart /home/oracle/app/oracle/product/12.2.0/dbhome_1
ExecStop=/home/oracle/app/oracle/product/12.2.0/dbhome_1/bin/dbshut /home/oracle/app/oracle/product/12.2.0/dbhome_1
User=oracle
[Install]
WantedBy=multi-user.target

设置服务开机自启动

sudo systemctl enable oracle-rdbms.service 

重新启动机器。

也可以手动启动/停止服务

sudo systemctl start oracle-rdbms.service 
sudo systemctl stop oracle-rdbms.service 
Logo

更多推荐