bootstrap-checks.asciidoc 7.7 KB

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