bootstrap-checks.asciidoc 12 KB

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