configuring.asciidoc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. LimitMEMLOCK=infinity
  75. ---------------------------------
  76. [[jvm-options]]
  77. ==== Setting JVM options
  78. The preferred method of setting Java Virtual Machine options (including
  79. system properties and JVM flags) is via the `jvm.options` configuration
  80. file. The default location of this file is `config/jvm.options` (when
  81. installing from the tar or zip distributions) and
  82. `/etc/elasticsearch/jvm.options` (when installing from the Debian or RPM
  83. packages). This file contains a line-delimited list of JVM arguments,
  84. which must begin with `-`. You can add custom JVM flags to this file and
  85. check this configuration into your version control system.
  86. An alternative mechanism for setting Java Virtual Machine options is
  87. via the `ES_JAVA_OPTS` environment variable. For instance:
  88. [source,sh]
  89. ---------------------------------
  90. export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"
  91. ./bin/elasticsearch
  92. ---------------------------------
  93. When using the RPM or Debian packages, `ES_JAVA_OPTS` can be specified in the
  94. <<sysconfig,system configuration file>>.