bootstrap-checks.asciidoc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. [float]
  17. === Development vs. production mode
  18. By default, Elasticsearch binds and publishes to `localhost`. This is
  19. fine for downloading and playing with Elasticsearch, and everyday
  20. development but it's useless for production systems. For a production
  21. installation to be reachable, it must either bind or publish to an
  22. external interface. Thus, we consider Elasticsearch to be in development
  23. mode if it does not bind nor publish to an external interface (the
  24. default), and is otherwise in production mode if it does bind or publish
  25. to an external interface.
  26. === Heap size check
  27. If a JVM is started with unequal initial and max heap size, it can be
  28. prone to pauses as the JVM heap is resized during system usage. To avoid
  29. these resize pauses, it's best to start the JVM with the initial heap
  30. size equal to the maximum heap size. Additionally, if
  31. <<bootstrap.memory_lock,`bootstrap.memory_lock`>> is enabled, the JVM will
  32. lock the initial size of the heap on startup. If the initial heap size
  33. is not equal to the maximum heap size, after a resize it will not be the
  34. case that all of the JVM heap is locked in memory. To pass the heap size
  35. check, you must configure the <<heap-size,heap size>>.
  36. === File descriptor check
  37. File descriptors are a Unix construct for tracking open "files". In Unix
  38. though, https://en.wikipedia.org/wiki/Everything_is_a_file[everything is
  39. a file]. For example, "files" could be a physical file, a virtual file
  40. (e.g., `/proc/loadavg`), or network sockets. Elasticsearch requires
  41. lots file descriptors (e.g., every shard is composed of multiple
  42. segments and other files, plus connections to other nodes, etc.). This
  43. bootstrap check is enforced on OS X and Linux. To pass the file
  44. descriptor check, you might have to configure <<file-descriptors,file
  45. descriptors>>.
  46. === Memory lock check
  47. When the JVM does a major garbage collection it touches every page of
  48. the heap. If any of those pages are swapped out to disk they will have
  49. to be swapped back in to memory. That causes lots of disk thrashing that
  50. Elasticsearch would much rather use to service requests. There are
  51. several ways to configure a system to disallow swapping. One way is by
  52. requesting the JVM to lock the heap in memory through `mlockall` (Unix)
  53. or virtual lock (Windows). This is done via the Elasticsearch setting
  54. <<bootstrap.memory_lock,`bootstrap.memory_lock`>>. However, there are cases
  55. where this setting can be passed to Elasticsearch but Elasticsearch is
  56. not able to lock the heap (e.g., if the `elasticsearch` user does not
  57. have `memlock unlimited`). The memory lock check verifies that *if* the
  58. `bootstrap.memory_lock` setting is enabled, that the JVM was successfully
  59. able to lock the heap. To pass the memory lock check, you might have to
  60. configure <<mlockall,`mlockall`>>.
  61. === Minimum master nodes check
  62. Elasticsearch uses a single master for managing cluster state but
  63. enables there to be multiple master-eligible nodes for
  64. high-availability. In the case of a partition, master-eligible nodes on
  65. each side of the partition might be elected as the acting master without
  66. knowing that there is a master on the side of the partition. This can
  67. lead to divergent cluster states potentially leading to data loss when
  68. the partition is healed. This is the notion of a split brain and it is
  69. the worst thing that can happen to an Elasticsearch cluster. But by
  70. configuring
  71. <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>> to be
  72. equal to a quorum of master-eligible nodes, it is not possible for the
  73. cluster to suffer from split brain because during a network partition
  74. there can be at most one side of the partition that contains a quorum of
  75. master nodes. The minimum master nodes check enforces that you've set
  76. <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>. To pass
  77. the minimum master nodes check, you must configure
  78. <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>.
  79. NOTE: The minimum master nodes check does not enforce that you've
  80. configured <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>
  81. correctly, only that you have it configured. Elasticsearch does log a
  82. warning message if it detects that
  83. <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>> is
  84. incorrectly configured based on the number of master-eligible nodes
  85. visible in the cluster state. Future versions of Elasticsearch will
  86. contain stricter enforcement of
  87. <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>.
  88. === Maximum number of threads check
  89. Elasticsearch executes requests by breaking the request down into stages
  90. and handing those stages off to different thread pool executors. There
  91. are different <<modules-threadpool,thread pool executors>> for a variety
  92. of tasks within Elasticsearch. Thus, Elasticsearch needs the ability to
  93. create a lot of threads. The maximum number of threads check ensures
  94. that the Elasticsearch process has the rights to create enough threads
  95. under normal use. This check is enforced only on Linux. If you are on
  96. Linux, to pass the maximum number of threads check, you must configure
  97. your system to allow the Elasticsearch process the ability to create at
  98. least 2048 threads. This can be done via `/etc/security/limits.conf`
  99. using the `nproc` setting (note that you might have to increase the
  100. limits for the `root` user too).
  101. [[max-size-virtual-memory-check]]
  102. === Maximum size virtual memory check
  103. Elasticsearch and Lucene use `mmap` to great effect to map portions of
  104. an index into the Elasticsearch address space. This keeps certain index
  105. data off the JVM heap but in memory for blazing fast access. For this to
  106. be effective, the Elasticsearch should have unlimited address space. The
  107. maximum size virtual memory check enforces that the Elasticsearch
  108. process has unlimited address space and is enforced only on Linux. To
  109. pass the maximum size virtual memory check, you must configure your
  110. system to allow the Elasticsearch process the ability to have unlimited
  111. address space. This can be done via `/etc/security/limits.conf` using
  112. the `as` setting to `unlimited` (note that you might have to increaes
  113. the limits for the `root` user too).
  114. === Maximum map count check
  115. Continuing from the previous <<max-size-virtual-memory-check,point>>, to
  116. use `mmap` effectively, Elasticsearch also requires the ability to
  117. create many memory-mapped areas. The maximum map count check checks that
  118. the kernel allows a process to have at least 262,144 memory-mapped areas
  119. and is enforced on Linux only. To pass the maximum map count check, you
  120. must configure `vm.max_map_count` via `sysctl` to be at least `262144`.
  121. === Client JVM check
  122. There are two different JVMs provided by OpenJDK-derived JVMs: the
  123. client JVM and the server JVM. These JVMs use different compilers for
  124. producing executable machine code from Java bytecode. The client JVM is
  125. tuned for startup time and memory footprint while the server JVM is
  126. tuned for maximizing performance. The difference in performance between
  127. the two VMs can be substantial. The client JVM check ensures that
  128. Elasticsearch is not running inside the client JVM. To pass the client
  129. JVM check, you must start Elasticsearch with the server VM. On modern
  130. systems and operating systems, the server VM is the
  131. default. Additionally, Elasticsearch is configured by default to force
  132. the server VM.