OpenSearch/docs/reference/setup/sysconfig/configuring.asciidoc

128 lines
4.1 KiB
Plaintext
Raw Normal View History

[[setting-system-settings]]
=== Configuring system settings
Where to configure systems settings depends on which package you have used to
install Elasticsearch, and which operating system you are using.
When using the `.zip` or `.tar.gz` packages, system settings can be configured:
* temporarily with <<ulimit,`ulimit`>>, or
* permanently in <<limits.conf,`/etc/security/limits.conf`>>.
When using the RPM or Debian packages, most system settings are set in the
<<sysconfig,system configuration file>>. However, systems which use systemd
require that system limits are specified in a
<<systemd,systemd configuration file>>.
[[ulimit]]
==== `ulimit`
On Linux systems, `ulimit` can be used to change resource limits on a
temporary basis. Limits usually need to be set as `root` before switching to
the user that will run Elasticsearch. For example, to set the number of
open file handles (`ulimit -n`) to 65,536, you can do the following:
[source,sh]
--------------------------------
sudo su <1>
ulimit -n 65536 <2>
su elasticsearch <3>
--------------------------------
<1> Become `root`.
<2> Change the max number of open files.
<3> Become the `elasticsearch` user in order to start Elasticsearch.
The new limit is only applied during the current session.
You can consult all currently applied limits with `ulimit -a`.
[[limits.conf]]
==== `/etc/security/limits.conf`
On Linux systems, persistent limits can be set for a particular user by
editing the `/etc/security/limits.conf` file. To set the maximum number of
open files for the `elasticsearch` user to 65,536, add the following line to
the `limits.conf` file:
[source,sh]
--------------------------------
elasticsearch - nofile 65536
--------------------------------
This change will only take effect the next time the `elasticsearch` user opens
a new session.
[NOTE]
.Ubuntu and `limits.conf`
===============================
Ubuntu ignores the `limits.conf` file for processes started by `init.d`. To
enable the `limits.conf` file, edit `/etc/pam.d/su` and uncomment the
following line:
[source,sh]
--------------------------------
# session required pam_limits.so
--------------------------------
===============================
[[sysconfig]]
==== Sysconfig file
When using the RPM or Debian packages, system settings and environment
variables can be specified in the system configuration file, which is located
in:
[horizontal]
RPM:: `/etc/sysconfig/elasticsearch`
Debian:: `/etc/default/elasticsearch`
However, for systems which uses `systemd`, system limits need to be specified
via <<systemd,systemd>>.
[[systemd]]
==== Systemd configuration
When using the RPM or Debian packages on systems that use
https://en.wikipedia.org/wiki/Systemd[systemd], system limits must be
specified via systemd.
The systemd service file (`/usr/lib/systemd/system/elasticsearch.service`)
contains the limits that are applied by default.
To override these, add a file called
`/etc/systemd/system/elasticsearch.service.d/elasticsearch.conf` and specify
any changes in that file, such as:
[source,sh]
---------------------------------
[Service]
LimitMEMLOCK=infinity
---------------------------------
Improve the out-of-the-box experience Elasticsearch can be run in a few different ways: - from the command line on Linux and Windows - as a service on Linux and Windows on both 32-bit client and 64-bit server VMs. We strive for a great out-of-the-box experience any of these combinations but today it is lacking on 32-bit client JVMs and on the Windows service. There are two deficiencies that arise: - on any 32-bit client JVM we fail to start out of the box because we force the server JVM in jvm.options - when installing the Windows service, the thread stack size must be specified in jvm.options This commit attempts to address these deficiencies. We should continue to force the server JVM because there are systems where the server JVM is not active by default (e.g., the 32-bit JDK on Windows). This does mean that if a user tries to run with a client JVM they will see a failure message at startup but this is the best that we can do if we want to continue to force the server JVM. Thus, this commit at least documents this situation. To improve the situation with installing the Windows service, this commit adds a default setting for the thread stack size. This default is chosen based on the default thread stack size across all 64-bit server JVMs. This means that if a user tries to run with a 32-bit JVM they could otherwise see significantly higher memory usage (this situation is complicated, it's really only on Windows where the extra memory usage is egregious, but cutting into the 32-bit address space on any system is bad). So this commit makes it so that the out-of-the-box experience is improved for the Windows service on 64-bit server JVMs and we document the need to adjust this setting on 32-bit JVMs. Again, we are focusing on the out-of-the-box experience here and this means optimizing for the best experience on any 64-bit server JVM as this covers the vast majority of the user base. The users that are on 32-bit JVMs will suffer a little bit but at least now any user on any 64-bit server JVM can start Elasticsearch out of the box. Finally, we fix some references to the jvm.options documentation. Relates #21920
2016-12-01 17:26:29 -05:00
[[jvm-options]]
==== Setting JVM options
The preferred method of setting Java Virtual Machine options (including
system properties and JVM flags) is via the `jvm.options` configuration
file. The default location of this file is `config/jvm.options` (when
installing from the tar or zip distributions) and
`/etc/elasticsearch/jvm.options` (when installing from the Debian or RPM
packages). This file contains a line-delimited list of JVM arguments,
which must begin with `-`. You can add custom JVM flags to this file and
check this configuration into your version control system.
An alternative mechanism for setting Java Virtual Machine options is
via the `ES_JAVA_OPTS` environment variable. For instance:
[source,sh]
---------------------------------
export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"
./bin/elasticsearch
---------------------------------
When using the RPM or Debian packages, `ES_JAVA_OPTS` can be specified in the
<<sysconfig,system configuration file>>.