2016-04-03 10:09:24 -04:00
|
|
|
[[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>
|
2019-01-16 17:19:12 -05:00
|
|
|
ulimit -n 65535 <2>
|
2016-04-03 10:09:24 -04:00
|
|
|
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]
|
|
|
|
--------------------------------
|
2019-01-16 17:19:12 -05:00
|
|
|
elasticsearch - nofile 65535
|
2016-04-03 10:09:24 -04:00
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2017-10-10 13:06:34 -04:00
|
|
|
To override them, add a file called
|
|
|
|
`/etc/systemd/system/elasticsearch.service.d/override.conf` (alternatively,
|
|
|
|
you may run `sudo systemctl edit elasticsearch` which opens the file
|
|
|
|
automatically inside your default editor). Set any changes in this file,
|
|
|
|
such as:
|
2016-04-03 10:09:24 -04:00
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
---------------------------------
|
2016-12-07 19:41:59 -05:00
|
|
|
[Service]
|
2016-04-03 10:09:24 -04:00
|
|
|
LimitMEMLOCK=infinity
|
|
|
|
---------------------------------
|
|
|
|
|
2017-10-10 13:06:34 -04:00
|
|
|
Once finished, run the following command to reload units:
|
|
|
|
|
|
|
|
[source,sh]
|
|
|
|
---------------------------------
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
---------------------------------
|