bootstrap-checks.asciidoc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. [[bootstrap-checks]]
  2. == Bootstrap Checks
  3. Collectively, we have a lot of experience with users suffering
  4. unexpected issues because they have not configured
  5. <<important-settings,important settings>>. In previous versions of
  6. Elasticsearch, misconfiguration of some of these settings were logged
  7. as warnings. Understandably, users sometimes miss these log messages.
  8. To ensure that these settings receive the attention that they deserve,
  9. Elasticsearch has bootstrap checks upon startup.
  10. These bootstrap checks inspect a variety of Elasticsearch and system
  11. settings and compare them to values that are safe for the operation of
  12. Elasticsearch. If Elasticsearch is in development mode, any bootstrap
  13. checks that fail appear as warnings in the Elasticsearch log. If
  14. Elasticsearch is in production mode, any bootstrap checks that fail will
  15. cause Elasticsearch to refuse to start.
  16. There are some bootstrap checks that are always enforced to prevent
  17. Elasticsearch from running with incompatible settings. These checks are
  18. documented individually.
  19. [float]
  20. === Development vs. production mode
  21. By default, Elasticsearch binds and publishes to `localhost`. This is
  22. fine for downloading and playing with Elasticsearch, and everyday
  23. development but it's useless for production systems. For a production
  24. installation to be reachable, it must either bind or publish to an
  25. external interface. Thus, we consider Elasticsearch to be in development
  26. mode if it does not bind nor publish to an external interface (the
  27. default), and is otherwise in production mode if it does bind or publish
  28. to an external interface.
  29. === Heap size check
  30. If a JVM is started with unequal initial and max heap size, it can be
  31. prone to pauses as the JVM heap is resized during system usage. To avoid
  32. these resize pauses, it's best to start the JVM with the initial heap
  33. size equal to the maximum heap size. Additionally, if
  34. <<bootstrap.memory_lock,`bootstrap.memory_lock`>> is enabled, the JVM will
  35. lock the initial size of the heap on startup. If the initial heap size
  36. is not equal to the maximum heap size, after a resize it will not be the
  37. case that all of the JVM heap is locked in memory. To pass the heap size
  38. check, you must configure the <<heap-size,heap size>>.
  39. === File descriptor check
  40. File descriptors are a Unix construct for tracking open "files". In Unix
  41. though, https://en.wikipedia.org/wiki/Everything_is_a_file[everything is
  42. a file]. For example, "files" could be a physical file, a virtual file
  43. (e.g., `/proc/loadavg`), or network sockets. Elasticsearch requires
  44. lots file descriptors (e.g., every shard is composed of multiple
  45. segments and other files, plus connections to other nodes, etc.). This
  46. bootstrap check is enforced on OS X and Linux. To pass the file
  47. descriptor check, you might have to configure <<file-descriptors,file
  48. descriptors>>.
  49. === Memory lock check
  50. When the JVM does a major garbage collection it touches every page of
  51. the heap. If any of those pages are swapped out to disk they will have
  52. to be swapped back in to memory. That causes lots of disk thrashing that
  53. Elasticsearch would much rather use to service requests. There are
  54. several ways to configure a system to disallow swapping. One way is by
  55. requesting the JVM to lock the heap in memory through `mlockall` (Unix)
  56. or virtual lock (Windows). This is done via the Elasticsearch setting
  57. <<bootstrap.memory_lock,`bootstrap.memory_lock`>>. However, there are cases
  58. where this setting can be passed to Elasticsearch but Elasticsearch is
  59. not able to lock the heap (e.g., if the `elasticsearch` user does not
  60. have `memlock unlimited`). The memory lock check verifies that *if* the
  61. `bootstrap.memory_lock` setting is enabled, that the JVM was successfully
  62. able to lock the heap. To pass the memory lock check, you might have to
  63. configure <<mlockall,`mlockall`>>.
  64. === Maximum number of threads check
  65. Elasticsearch executes requests by breaking the request down into stages
  66. and handing those stages off to different thread pool executors. There
  67. are different <<modules-threadpool,thread pool executors>> for a variety
  68. of tasks within Elasticsearch. Thus, Elasticsearch needs the ability to
  69. create a lot of threads. The maximum number of threads check ensures
  70. that the Elasticsearch process has the rights to create enough threads
  71. under normal use. This check is enforced only on Linux. If you are on
  72. Linux, to pass the maximum number of threads check, you must configure
  73. your system to allow the Elasticsearch process the ability to create at
  74. least 2048 threads. This can be done via `/etc/security/limits.conf`
  75. using the `nproc` setting (note that you might have to increase the
  76. limits for the `root` user too).
  77. [[max-size-virtual-memory-check]]
  78. === Maximum size virtual memory check
  79. Elasticsearch and Lucene use `mmap` to great effect to map portions of
  80. an index into the Elasticsearch address space. This keeps certain index
  81. data off the JVM heap but in memory for blazing fast access. For this to
  82. be effective, the Elasticsearch should have unlimited address space. The
  83. maximum size virtual memory check enforces that the Elasticsearch
  84. process has unlimited address space and is enforced only on Linux. To
  85. pass the maximum size virtual memory check, you must configure your
  86. system to allow the Elasticsearch process the ability to have unlimited
  87. address space. This can be done via `/etc/security/limits.conf` using
  88. the `as` setting to `unlimited` (note that you might have to increaes
  89. the limits for the `root` user too).
  90. === Maximum map count check
  91. Continuing from the previous <<max-size-virtual-memory-check,point>>, to
  92. use `mmap` effectively, Elasticsearch also requires the ability to
  93. create many memory-mapped areas. The maximum map count check checks that
  94. the kernel allows a process to have at least 262,144 memory-mapped areas
  95. and is enforced on Linux only. To pass the maximum map count check, you
  96. must configure `vm.max_map_count` via `sysctl` to be at least `262144`.
  97. === Client JVM check
  98. There are two different JVMs provided by OpenJDK-derived JVMs: the
  99. client JVM and the server JVM. These JVMs use different compilers for
  100. producing executable machine code from Java bytecode. The client JVM is
  101. tuned for startup time and memory footprint while the server JVM is
  102. tuned for maximizing performance. The difference in performance between
  103. the two VMs can be substantial. The client JVM check ensures that
  104. Elasticsearch is not running inside the client JVM. To pass the client
  105. JVM check, you must start Elasticsearch with the server VM. On modern
  106. systems and operating systems, the server VM is the
  107. default. Additionally, Elasticsearch is configured by default to force
  108. the server VM.
  109. === OnError and OnOutOfMemoryError checks
  110. The JVM options `OnError` and `OnOutOfMemoryError` enable executing
  111. arbitrary commands if the JVM encounters a fatal error (`OnError`) or an
  112. `OutOfMemoryError` (`OnOutOfMemoryError`). However, by default,
  113. Elasticsearch system call filters (seccomp) are enabled and these
  114. filters prevent forking. Thus, using `OnError` or `OnOutOfMemoryError`
  115. and system call filters are incompatible. The `OnError` and
  116. `OnOutOfMemoryError` checks prevent Elasticsearch from starting if
  117. either of these JVM options are used and system call filters are
  118. enabled. This check is always enforced. To pass this check do not enable
  119. `OnError` nor `OnOutOfMemoryError`; instead, upgrade to Java 8u92 and
  120. use the JVM flag `ExitOnOutOfMemoryError`. While this does not have the
  121. full capabilities of `OnError` nor `OnOutOfMemoryError`, arbitrary
  122. forking will not be supported with seccomp enabled.