configuring.asciidoc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 these, add a file called
  70. `/etc/systemd/system/elasticsearch.service.d/elasticsearch.conf` and specify
  71. any changes in that file, such as:
  72. [source,sh]
  73. ---------------------------------
  74. [Service]
  75. LimitMEMLOCK=infinity
  76. ---------------------------------
  77. [[jvm-options]]
  78. ==== Setting JVM options
  79. The preferred method of setting Java Virtual Machine options (including
  80. system properties and JVM flags) is via the `jvm.options` configuration
  81. file. The default location of this file is `config/jvm.options` (when
  82. installing from the tar or zip distributions) and
  83. `/etc/elasticsearch/jvm.options` (when installing from the Debian or RPM
  84. packages). This file contains a line-delimited list of JVM arguments,
  85. which must begin with `-`. You can add custom JVM flags to this file and
  86. check this configuration into your version control system.
  87. An alternative mechanism for setting Java Virtual Machine options is
  88. via the `ES_JAVA_OPTS` environment variable. For instance:
  89. [source,sh]
  90. ---------------------------------
  91. export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"
  92. ./bin/elasticsearch
  93. ---------------------------------
  94. When using the RPM or Debian packages, `ES_JAVA_OPTS` can be specified in the
  95. <<sysconfig,system configuration file>>.
  96. The JVM has a built-in mechanism for observing the `JAVA_TOOL_OPTIONS`
  97. environment variable. We intentionally ignore this environment variable in our
  98. packaging scripts. The primary reason for this is that on some OS (e.g., Ubuntu)
  99. there are agents installed by default via this environment variable that we do
  100. not want interfering with Elasticsearch.
  101. Additionally, some other Java programs support the `JAVA_OPTS` environment
  102. variable. This is *not* a mechanism built into the JVM but instead a convention
  103. in the ecosystem. However, we do not support this environment variable, instead
  104. supporting setting JVM options via the `jvm.options` file or the environment
  105. variable `ES_JAVA_OPTS` as above.