bootstrap-checks.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. === Maximum number of threads check
  87. Elasticsearch executes requests by breaking the request down into stages
  88. and handing those stages off to different thread pool executors. There
  89. are different <<modules-threadpool,thread pool executors>> for a variety
  90. of tasks within Elasticsearch. Thus, Elasticsearch needs the ability to
  91. create a lot of threads. The maximum number of threads check ensures
  92. that the Elasticsearch process has the rights to create enough threads
  93. under normal use. This check is enforced only on Linux. If you are on
  94. Linux, to pass the maximum number of threads check, you must configure
  95. your system to allow the Elasticsearch process the ability to create at
  96. least 2048 threads. This can be done via `/etc/security/limits.conf`
  97. using the `nproc` setting (note that you might have to increase the
  98. limits for the `root` user too).
  99. [[max-size-virtual-memory-check]]
  100. === Maximum size virtual memory check
  101. Elasticsearch and Lucene use `mmap` to great effect to map portions of
  102. an index into the Elasticsearch address space. This keeps certain index
  103. data off the JVM heap but in memory for blazing fast access. For this to
  104. be effective, the Elasticsearch should have unlimited address space. The
  105. maximum size virtual memory check enforces that the Elasticsearch
  106. process has unlimited address space and is enforced only on Linux. To
  107. pass the maximum size virtual memory check, you must configure your
  108. system to allow the Elasticsearch process the ability to have unlimited
  109. address space. This can be done via `/etc/security/limits.conf` using
  110. the `as` setting to `unlimited` (note that you might have to increase
  111. the limits for the `root` user too).
  112. === Maximum map count check
  113. Continuing from the previous <<max-size-virtual-memory-check,point>>, to
  114. use `mmap` effectively, Elasticsearch also requires the ability to
  115. create many memory-mapped areas. The maximum map count check checks that
  116. the kernel allows a process to have at least 262,144 memory-mapped areas
  117. and is enforced on Linux only. To pass the maximum map count check, you
  118. must configure `vm.max_map_count` via `sysctl` to be at least `262144`.
  119. === Client JVM check
  120. There are two different JVMs provided by OpenJDK-derived JVMs: the
  121. client JVM and the server JVM. These JVMs use different compilers for
  122. producing executable machine code from Java bytecode. The client JVM is
  123. tuned for startup time and memory footprint while the server JVM is
  124. tuned for maximizing performance. The difference in performance between
  125. the two VMs can be substantial. The client JVM check ensures that
  126. Elasticsearch is not running inside the client JVM. To pass the client
  127. JVM check, you must start Elasticsearch with the server VM. On modern
  128. systems and operating systems, the server VM is the
  129. default. Additionally, Elasticsearch is configured by default to force
  130. the server VM.
  131. === Use serial collector check
  132. There are various garbage collectors for the OpenJDK-derived JVMs
  133. targeting different workloads. The serial collector in particular is
  134. best suited for single logical CPU machines or extremely small heaps,
  135. neither of which are suitable for running Elasticsearch. Using the
  136. serial collector with Elasticsearch can be devastating for performance.
  137. The serial collector check ensures that Elasticsearch is not configured
  138. to run with the serial collector. To pass the serial collector check,
  139. you must not start Elasticsearch with the serial collector (whether it's
  140. from the defaults for the JVM that you're using, or you've explicitly
  141. specified it with `-XX:+UseSerialGC`). Note that the default JVM
  142. configuration that ship with Elasticsearch configures Elasticsearch to
  143. use the CMS collector.
  144. === System call filter check
  145. Elasticsearch installs system call filters of various flavors depending
  146. on the operating system (e.g., seccomp on Linux). These system call
  147. filters are installed to prevent the ability to execute system calls
  148. related to forking as a defense mechanism against arbitrary code
  149. execution attacks on Elasticsearch The system call filter check ensures
  150. that if system call filters are enabled, then they were successfully
  151. installed. To pass the system call filter check you must either fix any
  152. configuration errors on your system that prevented system call filters
  153. from installing (check your logs), or *at your own risk* disable system
  154. call filters by setting `bootstrap.system_call_filter` to `false`.
  155. === OnError and OnOutOfMemoryError checks
  156. The JVM options `OnError` and `OnOutOfMemoryError` enable executing
  157. arbitrary commands if the JVM encounters a fatal error (`OnError`) or an
  158. `OutOfMemoryError` (`OnOutOfMemoryError`). However, by default,
  159. Elasticsearch system call filters (seccomp) are enabled and these
  160. filters prevent forking. Thus, using `OnError` or `OnOutOfMemoryError`
  161. and system call filters are incompatible. The `OnError` and
  162. `OnOutOfMemoryError` checks prevent Elasticsearch from starting if
  163. either of these JVM options are used and system call filters are
  164. enabled. This check is always enforced. To pass this check do not enable
  165. `OnError` nor `OnOutOfMemoryError`; instead, upgrade to Java 8u92 and
  166. use the JVM flag `ExitOnOutOfMemoryError`. While this does not have the
  167. full capabilities of `OnError` nor `OnOutOfMemoryError`, arbitrary
  168. forking will not be supported with seccomp enabled.
  169. === Early-access check
  170. The OpenJDK project provides early-access snapshots of upcoming releases. These
  171. releases are not suitable for production. The early-access check detects these
  172. early-access snapshots. To pass this check, you must start Elasticsearch on a
  173. release build of the JVM.
  174. === G1GC check
  175. Early versions of the HotSpot JVM that shipped with JDK 8 are known to
  176. have issues that can lead to index corruption when the G1GC collector is
  177. enabled. The versions impacted are those earlier than the version of
  178. HotSpot that shipped with JDK 8u40. The G1GC check detects these early
  179. versions of the HotSpot JVM.