configuring.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. [[setting-system-settings]]
  2. === Configuring system settings
  3. Where to configure systems settings depends on which package you have used to
  4. install Elasticsearch, and which operating system you are using.
  5. When using the `.zip` or `.tar.gz` packages, system settings can be configured:
  6. * temporarily with <<ulimit,`ulimit`>>, or
  7. * permanently in <<limits.conf,`/etc/security/limits.conf`>>.
  8. When using the RPM or Debian packages, most system settings are set in the
  9. <<sysconfig,system configuration file>>. However, systems which use systemd
  10. require that system limits are specified in a
  11. <<systemd,systemd configuration file>>.
  12. [[ulimit]]
  13. ==== `ulimit`
  14. On Linux systems, `ulimit` can be used to change resource limits on a
  15. temporary basis. Limits usually need to be set as `root` before switching to
  16. the user that will run Elasticsearch. For example, to set the number of
  17. open file handles (`ulimit -n`) to 65,536, you can do the following:
  18. [source,sh]
  19. --------------------------------
  20. sudo su <1>
  21. ulimit -n 65536 <2>
  22. su elasticsearch <3>
  23. --------------------------------
  24. <1> Become `root`.
  25. <2> Change the max number of open files.
  26. <3> Become the `elasticsearch` user in order to start Elasticsearch.
  27. The new limit is only applied during the current session.
  28. You can consult all currently applied limits with `ulimit -a`.
  29. [[limits.conf]]
  30. ==== `/etc/security/limits.conf`
  31. On Linux systems, persistent limits can be set for a particular user by
  32. editing the `/etc/security/limits.conf` file. To set the maximum number of
  33. open files for the `elasticsearch` user to 65,536, add the following line to
  34. the `limits.conf` file:
  35. [source,sh]
  36. --------------------------------
  37. elasticsearch - nofile 65536
  38. --------------------------------
  39. This change will only take effect the next time the `elasticsearch` user opens
  40. a new session.
  41. [NOTE]
  42. .Ubuntu and `limits.conf`
  43. ===============================
  44. Ubuntu ignores the `limits.conf` file for processes started by `init.d`. To
  45. enable the `limits.conf` file, edit `/etc/pam.d/su` and uncomment the
  46. following line:
  47. [source,sh]
  48. --------------------------------
  49. # session required pam_limits.so
  50. --------------------------------
  51. ===============================
  52. [[sysconfig]]
  53. ==== Sysconfig file
  54. When using the RPM or Debian packages, system settings and environment
  55. variables can be specified in the system configuration file, which is located
  56. in:
  57. [horizontal]
  58. RPM:: `/etc/sysconfig/elasticsearch`
  59. Debian:: `/etc/default/elasticsearch`
  60. However, for systems which uses `systemd`, system limits need to be specified
  61. via <<systemd,systemd>>.
  62. [[systemd]]
  63. ==== Systemd configuration
  64. When using the RPM or Debian packages on systems that use
  65. https://en.wikipedia.org/wiki/Systemd[systemd], system limits must be
  66. specified via systemd.
  67. The systemd service file (`/usr/lib/systemd/system/elasticsearch.service`)
  68. contains the limits that are applied by default.
  69. To override them, add a file called
  70. `/etc/systemd/system/elasticsearch.service.d/override.conf` (alternatively,
  71. you may run `sudo systemctl edit elasticsearch` which opens the file
  72. automatically inside your default editor). Set any changes in this file,
  73. such as:
  74. [source,sh]
  75. ---------------------------------
  76. [Service]
  77. LimitMEMLOCK=infinity
  78. ---------------------------------
  79. Once finished, run the following command to reload units:
  80. [source,sh]
  81. ---------------------------------
  82. sudo systemctl daemon-reload
  83. ---------------------------------
  84. [[jvm-options]]
  85. ==== Setting JVM options
  86. The preferred method of setting Java Virtual Machine options (including
  87. system properties and JVM flags) is via the `jvm.options` configuration
  88. file. The default location of this file is `config/jvm.options` (when
  89. installing from the tar or zip distributions) and
  90. `/etc/elasticsearch/jvm.options` (when installing from the Debian or RPM
  91. packages). This file contains a line-delimited list of JVM arguments,
  92. which must begin with `-`. You can add custom JVM flags to this file and
  93. check this configuration into your version control system.
  94. An alternative mechanism for setting Java Virtual Machine options is
  95. via the `ES_JAVA_OPTS` environment variable. For instance:
  96. [source,sh]
  97. ---------------------------------
  98. export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"
  99. ./bin/elasticsearch
  100. ---------------------------------
  101. When using the RPM or Debian packages, `ES_JAVA_OPTS` can be specified in the
  102. <<sysconfig,system configuration file>>.
  103. The JVM has a built-in mechanism for observing the `JAVA_TOOL_OPTIONS`
  104. environment variable. We intentionally ignore this environment variable in our
  105. packaging scripts. The primary reason for this is that on some OS (e.g., Ubuntu)
  106. there are agents installed by default via this environment variable that we do
  107. not want interfering with Elasticsearch.
  108. Additionally, some other Java programs support the `JAVA_OPTS` environment
  109. variable. This is *not* a mechanism built into the JVM but instead a convention
  110. in the ecosystem. However, we do not support this environment variable, instead
  111. supporting setting JVM options via the `jvm.options` file or the environment
  112. variable `ES_JAVA_OPTS` as above.