Oracle database (RDBMS) systemd startup script
Oracle database systemd startup script is a common enough topic. That said – due to possible changes with how systemd handles limits, it could be that the context of oracle service used by systemd service would have different user limitations than when oracle startup command is called manually.
Assumptions:
- Oracle user is ‘oracle’
- Oracle group is ‘dba’
- ORACLE_HOME is /oracle/19c
- Ulimit defined correctly in /etc/security/limits.conf or /etc/security/limits.d/oracle-database-preinstall-19c.conf
Now, systemd unit requires entries to match NOFILE (number of open files) and MEMLOCK (maximum locked shared memory). An example of a working file (adjust the relevant parameters to your needs):
[Unit]
Description=Oracle 19c Boot Service.
After=network.target
[Service]
Type=simple
RemainAfterExit=yes
User=oracle
Group=dba
LimitNOFILE=32768:524288
LimitMEMLOCK=231446M
Environment="ORACLE_HOME=/oracle/19c"
#ExecStart=/usr/bin/bash -lc "ulimit -a > /tmp/ulimit.txt ; /oracle/19c/bin/dbstart $ORACLE_HOME" >> 2>&1 &
ExecStart=/oracle/19c/bin/dbstart $ORACLE_HOME >> 2>&1 &
ExecStop=/oracle/19c/bin/dbshut $ORACLE_HOME >> 2>&1 &
TimeoutSec=120
[Install]
WantedBy=multi-user.target
Originally (i.e – without the Limit definitions) Systemd could not start a DB with large sized HugePages. It was able to start manually, however.
Throughout the debug process, I used the commented-out ExecStart entry to investigate the inherited limitations, and to allow comparison to the user’s defined one. I left the comment on purpose as a hint on how to investigate similar issues further. You can use this commented-out example to check additional suspects in case the service does not function as expected.