bootstrap-checks.asciidoc 9.6 KB

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