About a year ago I explained in the blog post Start OUD Servers on Boot using systemd how to start Oracle Unified Directory automatically on system startup. In the meantime a lot has changed, so has my unit file. The simple unit file actually worked quite well. Until the time came when I installed an updated Java version for OUD. At this point I did realize, that it is not really optimal to have the JAVA_HOME respectively OPENDS_JAVA_HOME in the unit file. It all happened on a system where I didn’t have root access. OUD couldn’t be started any more using systemd, because the Java home path in the unit file was no longer correct. A change request and a few days later the problem was solved. Nevertheless this was a good opportunity to optimize the OUD unit file and get rid of static information. JAVA_HOME does not explicitly have to be specified when starting OUD. It is usually specified within the java.properties see also blog post Change default JAVA_HOME for OUD Instance.
What has been changed in the current unit file?
- Environment The environment variable OPENDS_JAVA_HOME has been completely be removed.
start-dsdoes use the JAVA_HOME specified by the java.properties.
- WorkingDirectory The working directory has been set to the OUD instance home.
- PIDFile Since the service type is forking, this directive is used to set the path of the PID file for the OUD instance. The file contains the process ID number of the directory server process respectively JVM which is monitored.
- Restart Systemd will attempt to automatically restart the service on-failure.
- RestartSec Amount of time to wait before attempting to restart the service.
stop-dsdoes send a SIGTERM to the JVM to stop the directory server. This generates an exit code 143. By default, systemd interprets this as an error. By setting SuccessExitStatus we can overwrite this behavior and accept 143 or SIGTERM as successful.
- User and Group Has been set to oud/oud rather than oracle/osdba. User and group for OUD highly depends on your environment.
Below you see the revised version of the OUD unit file. The OUD instance home path has been replaced with the placeholder OUD_INSTANCE_HOME.
ExecReload=OUD_INSTANCE_HOME/OUD/bin/stop-ds --restart --quiet
This updated unit file is also part of the latest version of OUD Base, my environment scripts for OUD. If you want to use it, you have to replace OUD_INSTANCE_HOME with your specific OUD instance home path.
cat $cdl/oudbase/templates/etc/oud_instance.service \
sed -i "s|OUD_INSTANCE_HOME|/app/oud/instances/$OUD_INSTANCE|" \
Enable the new unit file by coping it to the systemd folder /etc/systemd/system.
Run systemctl daemon-reload and enable the new service.
sudo systemctl enable oud_$OUD_INSTANCE.service
You OUD instance can now be started / stopped with systemctl as explained in the first blog post about OUD and systemd.
Some references and links related to this blog post:
- Initial blog post about Start OUD Servers on Boot using systemd
- OraDBA Environment Scripts for OUD
- OraDBA Change default JAVA_HOME for OUD Instance
- More blog posts by OraDBA about Oracle Unified Directory
- OUD11g: How to Start OUD Servers on Boot [2019451.1]
- Oracle® Fusion Middleware Administering Oracle Unified Directory 11g Release 2 (18.104.22.168) create-rc-script
- Red Hat Enterprise Linux 7 System Administrator’s Guide Creating and Modifying systemd Unit Files
- Understanding Systemd Units and Unit Files
- Wikipedia systemd