configuring.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 65535 <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 65535
  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. ---------------------------------