Skip to Main Content

Stopping XE 18c properly when shutting down CentOs 7

You can configure automatically start and stop Oracle XE 18c database on operating system startup and shutdown. See details from installation guide. I did install XE 18c on CentOs 7 and executed steps mentioned in installation guide. When viewing database alert.log after system reboot, noticed that database wasn't actually stopped properly. Processes were just killed. I didn't investigate more why that happens on my system. For workaround I did revert steps mentioned in installation guide and created service file for systemd.

First stop XE database and revert automatically start and stop:

systemctl stop oracle-xe-18c
systemctl disable oracle-xe-18c

Create service file:

cat >> /usr/lib/systemd/system/ora-xe-18c.service << EOF
[Unit]
Description=Oracle 18c XE databases service
After=syslog.target network.target

[Service]
Type=forking
Restart=no
KillMode=none
TimeoutStopSec=10min
RemainAfterExit=yes
User=oracle
Group=oinstall
ExecStart=/opt/oracle/product/18c/dbhomeXE/bin/dbstart /opt/oracle/product/18c/dbhomeXE &
ExecStop=/opt/oracle/product/18c/dbhomeXE/bin/dbshut /opt/oracle/product/18c/dbhomeXE

[Install]
WantedBy=multi-user.target
EOF

Backup and modify /etc/oratab:

cp /etc/oratab /etc/oratab.backup_`date +%Y%m%d`
sed -i 's/XE:\/opt\/oracle\/product\/18c\/dbhomeXE:N/XE:\/opt\/oracle\/product\/18c\/dbhomeXE:Y/g' /etc/oratab

Enable new service and start XE database again:

systemctl daemon-reload
systemctl enable ora-xe-18c
systemctl start ora-xe-18c

Comments

No comments yet on this post