<?xml version="1.0" encoding="UTF-8"?>
<!--
! CCPL HEADER START
!
! This work is licensed under the Creative Commons
! Attribution-NonCommercial-NoDerivs 3.0 Unported License.
! To view a copy of this license, visit
! http://creativecommons.org/licenses/by-nc-nd/3.0/
! or send a letter to Creative Commons, 444 Castro Street,
! Suite 900, Mountain View, California, 94041, USA.
!
! You can also obtain a copy of the license at
! trunk/opendj/legal-notices/CC-BY-NC-ND.txt.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! If applicable, add the following below this CCPL HEADER, with the fields
! enclosed by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CCPL HEADER END
!
! Copyright 2011-2015 ForgeRock AS.
!
-->
<chapter xml:id='chap-server-process'
xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://docbook.org/ns/docbook
http://docbook.org/xml/5.0/xsd/docbook.xsd'
xmlns:xlink='http://www.w3.org/1999/xlink'>
<title>Managing Server Processes</title>
<para>Using the OpenDJ Control Panel, you can start and stop local servers.
You can also start and stop OpenDJ using command-line tools, and use the
operating system's capabilities for starting OpenDJ at boot time.</para>
<para>This chapter demonstrates how to start and stop server processes
with command line tools and using operating system capabilities. This
chapter also describes what OpenDJ directory server does during startup
and shutdown, and how it recovers following an abrupt shutdown such as
happens during a system crash or when you kill the server process using
system tools.</para>
<section xml:id="start-server">
<title>Starting a Server</title>
<indexterm><primary>Start server</primary></indexterm>
<itemizedlist>
<para>Use one of the following techniques.</para>
<listitem>
<para>
Use the
<link
xlink:show="new"
xlink:href="reference#start-ds-1"
xlink:role="http://docbook.org/xlink/role/olink"
><command>start-ds</command></link> command.
</para>
<screen>
$ <userinput>start-ds</userinput>
</screen>
<para>
Alternatively, you can specify the <option>--no-detach</option>
option to start the server in the foreground.
</para>
</listitem>
<listitem>
<para>(Linux) If OpenDJ directory server was installed from a .deb or .rpm
package, then service management scripts were created at setup time.</para>
<para>Use the <command>service opendj start</command> command.</para>
<screen>
centos# <userinput>service opendj start</userinput>
<computeroutput>Starting opendj (via systemctl): [ OK ]</computeroutput>
</screen>
<screen>
ubuntu$ <userinput>sudo service opendj start</userinput>
<computeroutput>$Starting opendj: > SUCCESS.</computeroutput>
</screen>
</listitem>
<listitem>
<para>
(UNIX) Create an RC script by using the
<link
xlink:show="new"
xlink:href="reference#create-rc-script-1"
xlink:role="http://docbook.org/xlink/role/olink"
><command>create-rc-script</command></link> command,
and then use the script to start the server.
</para>
<para>Unless you run OpenDJ as root, use the --userName
<replaceable>userName</replaceable> option to specify the user
who installed OpenDJ.</para>
<screen>
$ <userinput>sudo create-rc-script \
--outputFile /etc/init.d/opendj \
--userName mark</userinput>
$ <userinput>sudo /etc/init.d/opendj start</userinput>
</screen>
<para>For example, on Linux if you run OpenDJ as root, you can use the
RC script to start the server at system boot, and stop the server at
system shutdown.</para>
<screen>
$ <userinput>sudo update-rc.d opendj defaults</userinput>
<computeroutput>update-rc.d: warning: /etc/init.d/opendj missing LSB information
update-rc.d: see &lt;http://wiki.debian.org/LSBInitScripts&gt;
Adding system startup for /etc/init.d/opendj ...
/etc/rc0.d/K20opendj -> /init.d/opendj
/etc/rc1.d/K20opendj -> /init.d/opendj
/etc/rc6.d/K20opendj -> /init.d/opendj
/etc/rc2.d/S20opendj -> /init.d/opendj
/etc/rc3.d/S20opendj -> /init.d/opendj
/etc/rc4.d/S20opendj -> /init.d/opendj
/etc/rc5.d/S20opendj -> /init.d/opendj</computeroutput>
</screen>
</listitem>
<listitem>
<para>
(Windows) Register OpenDJ as a Windows Service by using the
<link
xlink:show="new"
xlink:href="reference#windows-service"
xlink:role="http://docbook.org/xlink/role/olink"
><command>windows-service</command></link> command,
and then manage the service through Windows administration tools.
</para>
<screen>
C:\path\to\opendj\bat> <userinput>windows-service.bat --enableService</userinput>
</screen>
</listitem>
</itemizedlist>
<para>By default OpenDJ saves a compressed version of the server
configuration used on successful startup. This ensures that the server
provides a "last known good" configuration, which can be used as a reference
or copied into the active configuration if the server fails to start with the
current active configuration. It is possible, though not usually recommended,
to turn this behavior off by changing the global server setting
<literal>save-config-on-successful-startup</literal> to
<literal>false</literal>.</para>
</section>
<section xml:id="stop-server">
<title>Stopping a Server</title>
<indexterm><primary>Stop server</primary></indexterm>
<itemizedlist>
<para>Use one of the following techniques.</para>
<listitem>
<para>
Use the
<link
xlink:show="new"
xlink:href="reference#stop-ds-1"
xlink:role="http://docbook.org/xlink/role/olink"
><command>stop-ds</command></link> command.
</para>
<screen>$ stop-ds</screen>
</listitem>
<listitem>
<para>(Linux) If OpenDJ directory server was installed from a .deb or .rpm
package, then service management scripts were created at setup time.</para>
<para>Use the <command>service opendj stop</command> command.</para>
<screen>
centos# <userinput>service opendj stop</userinput>
<computeroutput>Stopping opendj (via systemctl): [ OK ]</computeroutput>
</screen>
<screen>
ubuntu$ <userinput>sudo service opendj stop</userinput>
<computeroutput>$Stopping opendj: ... > SUCCESS.</computeroutput>
</screen>
</listitem>
<listitem>
<para>(UNIX) Create an RC script, and then use the script to stop
the server.</para>
<screen>
$ <userinput>sudo create-rc-script \
--outputFile /etc/init.d/opendj \
--userName mark</userinput>
$ <userinput>sudo /etc/init.d/opendj stop</userinput>
</screen>
</listitem>
<listitem>
<para>(Windows) Register OpenDJ as a Windows Service, and then manage
the service through Windows administration tools.</para>
<screen>
C:\path\to\opendj\bat> <userinput>windows-service.bat --enableService</userinput>
</screen>
</listitem>
</itemizedlist>
</section>
<section xml:id="restart-server">
<title>Restarting a Server</title>
<indexterm><primary>Restart server</primary></indexterm>
<itemizedlist>
<para>Use one of the following techniques.</para>
<listitem>
<para>Use the <command>stop-ds</command> command.</para>
<screen>
$ <userinput>stop-ds --restart</userinput>
</screen>
</listitem>
<listitem>
<para>(Linux) If OpenDJ directory server was installed from a .deb or .rpm
package, then service management scripts were created at setup time.</para>
<para>Use the <command>service opendj restart</command> command.</para>
<screen>
centos# <userinput>service opendj restart</userinput>
<computeroutput>Restarting opendj (via systemctl): [ OK ]</computeroutput>
</screen>
<screen>
ubuntu$ <userinput>sudo service opendj restart</userinput>
<computeroutput>$Stopping opendj: ... > SUCCESS.
$Starting opendj: > SUCCESS.</computeroutput>
</screen>
</listitem>
<listitem>
<para>(UNIX) Create an RC script, and then use the script to stop
the server.</para>
<screen>
$ <userinput>sudo create-rc-script \
--outputFile /etc/init.d/opendj \
--userName mark</userinput>
$ <userinput>/etc/init.d/opendj restart</userinput>
</screen>
</listitem>
<listitem>
<para>(Windows) Register OpenDJ as a Windows Service, and then manage
the service through Windows administration tools.</para>
<screen>
C:\path\to\opendj\bat> <userinput>windows-service.bat --enableService</userinput>
</screen>
</listitem>
</itemizedlist>
</section>
<section xml:id="crash-recovery">
<title>Server Recovery</title>
<indexterm>
<primary>Replication</primary>
<secondary>Crash recovery</secondary>
</indexterm>
<para>OpenDJ tends to show resilience when restarting after a crash or after
the server process is killed abruptly. OpenDJ might have to replay the last
few entries in a transaction log. Generally OpenDJ returns to service
quickly.</para>
<para>You can find Berkeley Java Edition database recovery messages in the
database log file, such as
<filename>/path/to/opendj/db/userRoot/je.info.0</filename>. The following
shows two example messages from that log, the first written at the beginning
of the recovery process, the second written at the end of the process.</para>
<programlisting language="none">
111104 10:23:48:967 CONFIG [/path/to/opendj/db/userRoot]Recovery
underway, found end of log
...
111104 10:23:49:015 CONFIG [/path/to/opendj/db/userRoot]Recovery finished:
Recovery Info ...
</programlisting>
<para>What can take some time during server startup is preloading database
content into memory when the server starts. Objects cached in memory do not
survive a crash. By default, OpenDJ does not cache objects in memory before
starting to accept client requests. You can however set a
<link xlink:href="${configRefBase}local-db-backend.html#preload-time-limit"
><literal>preload-time-limit</literal></link> for the database cache of your
backend if you do want to load objects into the database cache before
OpenDJ begins accepting client connections.</para>
</section>
</chapter>