bootstrap-checks.asciidoc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 to `localhost` for <<modules-http,HTTP>>
  22. and <<modules-transport,transport (internal)>> communication. This is
  23. fine for downloading and playing with Elasticsearch, and everyday
  24. development but it's useless for production systems. To form a cluster,
  25. Elasticsearch instances must be reachable via transport communication so
  26. they must bind transport to an external interface. Thus, we consider an
  27. Elasticsearch instance to be in development mode if it does not bind
  28. transport to an external interface (the default), and is otherwise in
  29. production mode if it does bind transport to an external interface. Note
  30. that HTTP can be configured independently of transport via
  31. <<modules-http,`http.host`>> and <<modules-transport,`transport.host`>>;
  32. this can be useful for configuring a single instance to be reachable via
  33. HTTP for testing purposes without triggering production mode. If you do
  34. want to force enforcement of the bootstrap checks independent of the
  35. binding of the transport protocal, you can set the system property
  36. `es.enforce.bootstrap.checks` to `true` (this can be useful on a
  37. single-node production system that does not bind transport to an external
  38. interface).
  39. === Heap size check
  40. If a JVM is started with unequal initial and max heap size, it can be
  41. prone to pauses as the JVM heap is resized during system usage. To avoid
  42. these resize pauses, it's best to start the JVM with the initial heap
  43. size equal to the maximum heap size. Additionally, if
  44. <<bootstrap.memory_lock,`bootstrap.memory_lock`>> is enabled, the JVM will
  45. lock the initial size of the heap on startup. If the initial heap size
  46. is not equal to the maximum heap size, after a resize it will not be the
  47. case that all of the JVM heap is locked in memory. To pass the heap size
  48. check, you must configure the <<heap-size,heap size>>.
  49. === File descriptor check
  50. File descriptors are a Unix construct for tracking open "files". In Unix
  51. though, https://en.wikipedia.org/wiki/Everything_is_a_file[everything is
  52. a file]. For example, "files" could be a physical file, a virtual file
  53. (e.g., `/proc/loadavg`), or network sockets. Elasticsearch requires
  54. lots of file descriptors (e.g., every shard is composed of multiple
  55. segments and other files, plus connections to other nodes, etc.). This
  56. bootstrap check is enforced on OS X and Linux. To pass the file
  57. descriptor check, you might have to configure <<file-descriptors,file
  58. descriptors>>.
  59. === Memory lock check
  60. When the JVM does a major garbage collection it touches every page of
  61. the heap. If any of those pages are swapped out to disk they will have
  62. to be swapped back in to memory. That causes lots of disk thrashing that
  63. Elasticsearch would much rather use to service requests. There are
  64. several ways to configure a system to disallow swapping. One way is by
  65. requesting the JVM to lock the heap in memory through `mlockall` (Unix)
  66. or virtual lock (Windows). This is done via the Elasticsearch setting
  67. <<bootstrap.memory_lock,`bootstrap.memory_lock`>>. However, there are cases
  68. where this setting can be passed to Elasticsearch but Elasticsearch is
  69. not able to lock the heap (e.g., if the `elasticsearch` user does not
  70. have `memlock unlimited`). The memory lock check verifies that *if* the
  71. `bootstrap.memory_lock` setting is enabled, that the JVM was successfully
  72. able to lock the heap. To pass the memory lock check, you might have to
  73. configure <<mlockall,`mlockall`>>.
  74. === Maximum number of threads check
  75. Elasticsearch executes requests by breaking the request down into stages
  76. and handing those stages off to different thread pool executors. There
  77. are different <<modules-threadpool,thread pool executors>> for a variety
  78. of tasks within Elasticsearch. Thus, Elasticsearch needs the ability to
  79. create a lot of threads. The maximum number of threads check ensures
  80. that the Elasticsearch process has the rights to create enough threads
  81. under normal use. This check is enforced only on Linux. If you are on
  82. Linux, to pass the maximum number of threads check, you must configure
  83. your system to allow the Elasticsearch process the ability to create at
  84. least 2048 threads. This can be done via `/etc/security/limits.conf`
  85. using the `nproc` setting (note that you might have to increase the
  86. limits for the `root` user too).
  87. [[max-size-virtual-memory-check]]
  88. === Maximum size virtual memory check
  89. Elasticsearch and Lucene use `mmap` to great effect to map portions of
  90. an index into the Elasticsearch address space. This keeps certain index
  91. data off the JVM heap but in memory for blazing fast access. For this to
  92. be effective, the Elasticsearch should have unlimited address space. The
  93. maximum size virtual memory check enforces that the Elasticsearch
  94. process has unlimited address space and is enforced only on Linux. To
  95. pass the maximum size virtual memory check, you must configure your
  96. system to allow the Elasticsearch process the ability to have unlimited
  97. address space. This can be done via `/etc/security/limits.conf` using
  98. the `as` setting to `unlimited` (note that you might have to increase
  99. the limits for the `root` user too).
  100. === Maximum map count check
  101. Continuing from the previous <<max-size-virtual-memory-check,point>>, to
  102. use `mmap` effectively, Elasticsearch also requires the ability to
  103. create many memory-mapped areas. The maximum map count check checks that
  104. the kernel allows a process to have at least 262,144 memory-mapped areas
  105. and is enforced on Linux only. To pass the maximum map count check, you
  106. must configure `vm.max_map_count` via `sysctl` to be at least `262144`.
  107. === Client JVM check
  108. There are two different JVMs provided by OpenJDK-derived JVMs: the
  109. client JVM and the server JVM. These JVMs use different compilers for
  110. producing executable machine code from Java bytecode. The client JVM is
  111. tuned for startup time and memory footprint while the server JVM is
  112. tuned for maximizing performance. The difference in performance between
  113. the two VMs can be substantial. The client JVM check ensures that
  114. Elasticsearch is not running inside the client JVM. To pass the client
  115. JVM check, you must start Elasticsearch with the server VM. On modern
  116. systems and operating systems, the server VM is the
  117. default. Additionally, Elasticsearch is configured by default to force
  118. the server VM.
  119. === Use serial collector check
  120. There are various garbage collectors for the OpenJDK-derived JVMs targeting
  121. different workloads. The serial collector in particular is best suited for
  122. single logical CPU machines or extremely small heaps, neither of which are
  123. suitable for running Elasticsearch. Using the serial collector with
  124. Elasticsearch can be devastating for performance. The serial collector check
  125. ensures that Elasticsearch is not configured to run with the serial
  126. collector. To pass the serial collector check, you must not start Elasticsearch
  127. with the serial collector (whether it's from the defaults for the JVM that
  128. you're using, or you've explicitly specified it with `-XX:+UseSerialGC`). Note
  129. that the default JVM configuration that ship with Elasticsearch configures
  130. Elasticsearch to use the CMS collector.
  131. === System call filter check
  132. Elasticsearch installs system call filters of various flavors depending on the
  133. operating system (e.g., seccomp on Linux). These system call filters are
  134. installed to prevent the ability to execute system calls related to forking as
  135. a defense mechanism against arbitrary code execution attacks on Elasticsearch
  136. The system call filter check ensures that if system call filters are enabled,
  137. then they were successfully installed. To pass the system call filter check you
  138. must either fix any configuration errors on your system that prevented system
  139. call filters from installing (check your logs), or *at your own risk* disable
  140. system call filters by setting `bootstrap.system_call_filter` to `false`.
  141. === OnError and OnOutOfMemoryError checks
  142. The JVM options `OnError` and `OnOutOfMemoryError` enable executing
  143. arbitrary commands if the JVM encounters a fatal error (`OnError`) or an
  144. `OutOfMemoryError` (`OnOutOfMemoryError`). However, by default,
  145. Elasticsearch system call filters (seccomp) are enabled and these
  146. filters prevent forking. Thus, using `OnError` or `OnOutOfMemoryError`
  147. and system call filters are incompatible. The `OnError` and
  148. `OnOutOfMemoryError` checks prevent Elasticsearch from starting if
  149. either of these JVM options are used and system call filters are
  150. enabled. This check is always enforced. To pass this check do not enable
  151. `OnError` nor `OnOutOfMemoryError`; instead, upgrade to Java 8u92 and
  152. use the JVM flag `ExitOnOutOfMemoryError`. While this does not have the
  153. full capabilities of `OnError` nor `OnOutOfMemoryError`, arbitrary
  154. forking will not be supported with seccomp enabled.
  155. === G1GC check
  156. Early versions of the HotSpot JVM that shipped with JDK 8 are known to have
  157. issues that can lead to index corruption when the G1GC collector is enabled.
  158. The versions impacted are those earlier than the version of HotSpot that
  159. shipped with JDK 8u40. The G1GC check detects these early versions of the
  160. HotSpot JVM.