{"id":2609,"date":"2018-05-16T17:12:23","date_gmt":"2018-05-16T15:12:23","guid":{"rendered":"http:\/\/www.oradba.ch\/?p=2609"},"modified":"2018-05-16T21:14:12","modified_gmt":"2018-05-16T19:14:12","slug":"oracle-unified-directory-systemd-unit-file","status":"publish","type":"post","link":"https:\/\/www.oradba.ch\/wordpress\/2018\/05\/oracle-unified-directory-systemd-unit-file\/","title":{"rendered":"Oracle Unified Directory systemd unit file"},"content":{"rendered":"<p>About a year ago I explained in the blog post <em><a href=\"https:\/\/www.oradba.ch\/wordpress\/2017\/05\/start-oud-servers-on-boot-using-systemd\/\">Start OUD Servers on Boot using systemd<\/a><\/em> 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&#8217;t have root access. OUD couldn&#8217;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 <a href=\"https:\/\/www.oradba.ch\/wordpress\/2016\/07\/change-default-java_home-for-oud-instance\/\">Change default JAVA_HOME for OUD Instance<\/a>.<\/p>\n<p>What has been changed in the current unit file?<\/p>\n<ul>\n<li><strong>Environment<\/strong> The environment variable OPENDS_JAVA_HOME has been completely be removed. <code class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">start-ds<\/code> does use the JAVA_HOME specified by the java.properties.<\/li>\n<li><strong>WorkingDirectory<\/strong> The working directory has been set to the OUD instance home.<\/li>\n<li><strong>PIDFile<\/strong> Since the service type is <em>forking<\/em>, 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.<\/li>\n<li><strong>Restart <\/strong>Systemd will attempt to automatically restart the service <em>on-failure<\/em>.<\/li>\n<li><strong>RestartSec<\/strong> Amount of time to wait before attempting to restart the service.<\/li>\n<li><strong>SuccessExitStatus<\/strong> <code class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">stop-ds<\/code> does 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.<\/li>\n<li><strong>User and Group<\/strong> Has been set to oud\/oud rather than oracle\/osdba. User and group for OUD highly depends on your environment.<\/li>\n<\/ul>\n<p>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.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">\r\n[Unit]\r\nDescription=OUD Instance\r\nWants=network.target\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\nUser=oud\r\nGroup=oud\r\nWorkingDirectory=OUD_INSTANCE_HOME\/OUD\r\nPIDFile=OUD_INSTANCE_HOME\/OUD\/logs\/server.pid\r\nExecStart=OUD_INSTANCE_HOME\/OUD\/bin\/start-ds --quiet\r\nExecStop=OUD_INSTANCE_HOME\/OUD\/bin\/stop-ds --quiet\r\nExecReload=OUD_INSTANCE_HOME\/OUD\/bin\/stop-ds --restart --quiet\r\nRestartSec=42s\r\nRestart=on-failure\r\nSuccessExitStatus=143 SIGTERM\r\nTimeoutSec=300\r\nStandardOutput=syslog+console\r\nStandardError=syslog+console\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\n<p>This updated unit file is also part of the latest version of <a href=\"https:\/\/github.com\/oehrlis\/oudbase\">OUD Base<\/a>, my <a href=\"https:\/\/www.oradba.ch\/wordpress\/2016\/11\/environment-scripts-for-oud\/\">environment scripts<\/a> for OUD. If you want to use it, you have to replace <em>OUD_INSTANCE_HOME<\/em> with your specific OUD instance home path.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">\r\nexport OUD_INSTANCE=&quot;oudtest&quot;\r\nexport OUD_INSTANCE_HOME=&quot;\/u00\/app\/oud\/instances\/$OUD_INSTANCE&quot;\r\nexport $cdl=&quot;\/u00\/app\/oud\/local&quot;\r\nexport $cda=&quot;\/u00\/app\/oud\/admin\/$OUD_INSTANCE&quot;\r\ncat $cdl\/oudbase\/templates\/etc\/oud_instance.service \\\r\n  &gt;$cda\/etc\/oud_$OUD_INSTANCE.service\r\nsed -i &quot;s|OUD_INSTANCE_HOME|\/app\/oud\/instances\/$OUD_INSTANCE|&quot; \\\r\n  $cda\/etc\/oud_$OUD_INSTANCE.service\r\ncat $cda\/etc\/oud_$OUD_INSTANCE.service\r\n<\/pre>\n<p>Enable the new unit file by coping it to the systemd folder <em>\/etc\/systemd\/system<\/em>. <\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">\r\nsudo cp $cda\/etc\/oud_$OUD_INSTANCE.service \\\r\n  \/etc\/systemd\/system\/oud_$OUD_INSTANCE.service\r\n<\/pre>\n<p>Run systemctl daemon-reload and enable the new service.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\">\r\nsudo systemctl daemon-reload\r\nsudo systemctl enable oud_$OUD_INSTANCE.service\r\n<\/pre>\n<p>You OUD instance can now be started \/ stopped with systemctl as explained in the first blog post about <a href=\"https:\/\/www.oradba.ch\/wordpress\/2017\/05\/start-oud-servers-on-boot-using-systemd\/\">OUD and systemd<\/a>.<\/p>\n<p>Some references and links related to this blog post:<\/p>\n<ul>\n<li>Initial blog post about <a href=\"https:\/\/www.oradba.ch\/wordpress\/2017\/05\/start-oud-servers-on-boot-using-systemd\/\">Start OUD Servers on Boot using systemd<\/a><\/li>\n<li>OraDBA <a href=\"https:\/\/www.oradba.ch\/wordpress\/2016\/11\/environment-scripts-for-oud\/\">Environment Scripts for OUD<\/a><\/li>\n<li>OraDBA <a href=\"https:\/\/www.oradba.ch\/wordpress\/2016\/07\/change-default-java_home-for-oud-instance\/\">Change default JAVA_HOME for OUD Instance<\/a><\/li>\n<li>More blog posts by OraDBA about <a href=\"https:\/\/www.oradba.ch\/wordpress\/category\/oud\/\">Oracle Unified Directory<\/a><\/li>\n<li>OUD11g: How to Start OUD Servers on Boot [<em><a href=\"https:\/\/support.oracle.com\/epmos\/faces\/DocumentDisplay?id=2019451.1\" target=\"_blank\">2019451.1<\/a><\/em>]<\/li>\n<li>Oracle\u00ae Fusion Middleware Administering Oracle Unified Directory 11g Release 2 (11.1.2.3) <a href=\"https:\/\/docs.oracle.com\/cd\/E52734_01\/oud\/OUDAG\/appendix_cli.htm#OUDAG01144\" target=\"_blank\">create-rc-script<\/a><\/li>\n<li>Red Hat Enterprise Linux 7 System Administrator&#8217;s Guide <a href=\"https:\/\/access.redhat.com\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/7\/html\/System_Administrators_Guide\/sect-Managing_Services_with_systemd-Unit_Files.html\" target=\"_blank\">Creating and Modifying systemd Unit Files<\/a><\/li>\n<li><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/understanding-systemd-units-and-unit-files\" target=\"_blank\">Understanding Systemd Units and Unit Files<\/a><\/li>\n<li>Wikipedia <a href=\"https:\/\/en.wikipedia.org\/wiki\/Systemd\">systemd<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New blog post on #Oracle #Unified #Directory and systemd unit file","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[73,142,178],"tags":[130,18,111],"class_list":["post-2609","post","type-post","status-publish","format-standard","hentry","category-linux-2","category-oud","category-oudbase","tag-trivadis","tag-trivadiscontent","tag-tvdsecexpert"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1aErb-G5","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2280,"url":"https:\/\/www.oradba.ch\/wordpress\/2017\/05\/start-oud-servers-on-boot-using-systemd\/","url_meta":{"origin":2609,"position":0},"title":"Start OUD Servers on Boot using systemd","author":"Stefan","date":"16. May 2017","format":false,"excerpt":"Starting Oracle Unified Directory on system boot is essential for production environment. Unfortunately OUD just provides a script to create the init.d script. But newer system in general use systemd initialise and startup. Nevertheless, creating a custom unit file for OUD is simple and straightforward. First, let's create a regular\u2026","rel":"","context":"In &quot;Linux&quot;","block_context":{"text":"Linux","link":"https:\/\/www.oradba.ch\/wordpress\/category\/linux-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2353,"url":"https:\/\/www.oradba.ch\/wordpress\/2017\/09\/start-odsm-on-boot-using-systemd\/","url_meta":{"origin":2609,"position":1},"title":"Start ODSM on boot using systemd","author":"Stefan","date":"7. September 2017","format":false,"excerpt":"A couple of month ago I wrote blog on how to start Oracle Unified Directory (OUD) on system boot (see Start OUD Servers on Boot using systemd) using a unit file and systemd. Quite a simple and straightforward way to start OUD. Why not using the same approach for ODSM?\u2026","rel":"","context":"In &quot;Oracle Unified Directory&quot;","block_context":{"text":"Oracle Unified Directory","link":"https:\/\/www.oradba.ch\/wordpress\/category\/oud\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2431,"url":"https:\/\/www.oradba.ch\/wordpress\/2017\/11\/install-oracle-unified-directory-12c-the-smart-way\/","url_meta":{"origin":2609,"position":2},"title":"Install Oracle Unified Directory 12c the smart way","author":"Stefan","date":"23. November 2017","format":false,"excerpt":"Installing Oracle Unified Directory has always been easy. The installation guide for OUD 11c as well OUD 12 is simple and straight forward. Additionally Oracle does provide a couple of MOS notes for different deployment scenarios. Nevertheless there is always room for improvement :-) During my work on OUD to\u2026","rel":"","context":"In &quot;Howto&quot;","block_context":{"text":"Howto","link":"https:\/\/www.oradba.ch\/wordpress\/category\/howto\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2786,"url":"https:\/\/www.oradba.ch\/wordpress\/2018\/09\/oracle-unified-directory-access-log-parsing-system-alps\/","url_meta":{"origin":2609,"position":3},"title":"Oracle Unified Directory Access Log Parsing System ALPS","author":"Stefan","date":"25. September 2018","format":false,"excerpt":"For one of my customers I had to analyse the log files of Oracle Unified Directory from time to time. In particular the access log file. During my research I came across the MOS note 2042620.1 and the Access Log Parsing System or short ALPS. ALPS is a small and\u2026","rel":"","context":"In &quot;Oracle Unified Directory&quot;","block_context":{"text":"Oracle Unified Directory","link":"https:\/\/www.oradba.ch\/wordpress\/category\/oud\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.oradba.ch\/wordpress\/wp-content\/uploads\/ALPS_Dashboard-300x221.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.oradba.ch\/wordpress\/wp-content\/uploads\/ALPS_Dashboard-300x221.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.oradba.ch\/wordpress\/wp-content\/uploads\/ALPS_Dashboard-300x221.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2761,"url":"https:\/\/www.oradba.ch\/wordpress\/2018\/08\/oracle-unified-directory-sslhandshakeexception-with-java-1-8-0_181\/","url_meta":{"origin":2609,"position":4},"title":"Oracle Unified Directory SSLHandshakeException with Java 1.8.0_181","author":"Stefan","date":"23. August 2018","format":false,"excerpt":"A couple of days ago I did update my Oracle Unified Directory Docker images with the latest bundle patch for OUD as well the latest java version. With the new Docker images I was about to reproduce a use case from a customer. Everything actually worked at first glance, but\u2026","rel":"","context":"In &quot;Oracle Unified Directory&quot;","block_context":{"text":"Oracle Unified Directory","link":"https:\/\/www.oradba.ch\/wordpress\/category\/oud\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2456,"url":"https:\/\/www.oradba.ch\/wordpress\/2017\/12\/oracle-unified-directory-on-docker\/","url_meta":{"origin":2609,"position":5},"title":"Oracle Unified Directory on Docker","author":"Stefan","date":"13. December 2017","format":false,"excerpt":"A bit a while ago I've started to use Docker for miscellaneous purposes. Not really an early adopter, but I still hope I caught the train just in time. :-) In one of my customer project, I did have to set up a couple of OUD instance to develop and\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/www.oradba.ch\/wordpress\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.oradba.ch\/wordpress\/wp-content\/uploads\/OUD_Moby-300x209.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/posts\/2609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/comments?post=2609"}],"version-history":[{"count":5,"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/posts\/2609\/revisions"}],"predecessor-version":[{"id":2615,"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/posts\/2609\/revisions\/2615"}],"wp:attachment":[{"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/media?parent=2609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/categories?post=2609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oradba.ch\/wordpress\/wp-json\/wp\/v2\/tags?post=2609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}