bootstrap-checks.asciidoc 13 KB

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