| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 | [[bootstrap-checks]]== Bootstrap ChecksCollectively, we have a lot of experience with users sufferingunexpected issues because they have not configured<<important-settings,important settings>>. In previous versions ofElasticsearch, misconfiguration of some of these settings were loggedas warnings. Understandably, users sometimes miss these log messages.To ensure that these settings receive the attention that they deserve,Elasticsearch has bootstrap checks upon startup.These bootstrap checks inspect a variety of Elasticsearch and systemsettings and compare them to values that are safe for the operation ofElasticsearch. If Elasticsearch is in development mode, any bootstrapchecks that fail appear as warnings in the Elasticsearch log. IfElasticsearch is in production mode, any bootstrap checks that fail willcause Elasticsearch to refuse to start.There are some bootstrap checks that are always enforced to preventElasticsearch from running with incompatible settings. These checks aredocumented individually.[float]=== Development vs. production modeBy default, Elasticsearch binds to `localhost` for <<modules-http,HTTP>>and <<modules-transport,transport (internal)>> communication. This isfine for downloading and playing with Elasticsearch, and everydaydevelopment but it's useless for production systems. To form a cluster,Elasticsearch instances must be reachable via transport communication sothey must bind transport to an external interface. Thus, we consider anElasticsearch instance to be in development mode if it does not bindtransport to an external interface (the default), and is otherwise inproduction mode if it does bind transport to an external interface. Notethat HTTP can be configured independently of transport via<<modules-http,`http.host`>> and <<modules-transport,`transport.host`>>;this can be useful for configuring a single instance to be reachable viaHTTP for testing purposes without triggering production mode.=== Heap size checkIf a JVM is started with unequal initial and max heap size, it can beprone to pauses as the JVM heap is resized during system usage. To avoidthese resize pauses, it's best to start the JVM with the initial heapsize equal to the maximum heap size. Additionally, if<<bootstrap.memory_lock,`bootstrap.memory_lock`>> is enabled, the JVM willlock the initial size of the heap on startup. If the initial heap sizeis not equal to the maximum heap size, after a resize it will not be thecase that all of the JVM heap is locked in memory. To pass the heap sizecheck, you must configure the <<heap-size,heap size>>.=== File descriptor checkFile descriptors are a Unix construct for tracking open "files". In Unixthough, https://en.wikipedia.org/wiki/Everything_is_a_file[everything isa file]. For example, "files" could be a physical file, a virtual file(e.g., `/proc/loadavg`), or network sockets. Elasticsearch requireslots of file descriptors (e.g., every shard is composed of multiplesegments and other files, plus connections to other nodes, etc.). Thisbootstrap check is enforced on OS X and Linux. To pass the filedescriptor check, you might have to configure <<file-descriptors,filedescriptors>>.=== Memory lock checkWhen the JVM does a major garbage collection it touches every page ofthe heap. If any of those pages are swapped out to disk they will haveto be swapped back in to memory. That causes lots of disk thrashing thatElasticsearch would much rather use to service requests. There areseveral ways to configure a system to disallow swapping. One way is byrequesting the JVM to lock the heap in memory through `mlockall` (Unix)or virtual lock (Windows). This is done via the Elasticsearch setting<<bootstrap.memory_lock,`bootstrap.memory_lock`>>. However, there are caseswhere this setting can be passed to Elasticsearch but Elasticsearch isnot able to lock the heap (e.g., if the `elasticsearch` user does nothave `memlock unlimited`). The memory lock check verifies that *if* the`bootstrap.memory_lock` setting is enabled, that the JVM was successfullyable to lock the heap. To pass the memory lock check, you might have toconfigure <<mlockall,`mlockall`>>.=== Maximum number of threads checkElasticsearch executes requests by breaking the request down into stagesand handing those stages off to different thread pool executors. Thereare different <<modules-threadpool,thread pool executors>> for a varietyof tasks within Elasticsearch. Thus, Elasticsearch needs the ability tocreate a lot of threads. The maximum number of threads check ensuresthat the Elasticsearch process has the rights to create enough threadsunder normal use. This check is enforced only on Linux. If you are onLinux, to pass the maximum number of threads check, you must configureyour system to allow the Elasticsearch process the ability to create atleast 2048 threads. This can be done via `/etc/security/limits.conf`using the `nproc` setting (note that you might have to increase thelimits for the `root` user too).[[max-size-virtual-memory-check]]=== Maximum size virtual memory checkElasticsearch and Lucene use `mmap` to great effect to map portions ofan index into the Elasticsearch address space. This keeps certain indexdata off the JVM heap but in memory for blazing fast access. For this tobe effective, the Elasticsearch should have unlimited address space. Themaximum size virtual memory check enforces that the Elasticsearchprocess has unlimited address space and is enforced only on Linux. Topass the maximum size virtual memory check, you must configure yoursystem to allow the Elasticsearch process the ability to have unlimitedaddress space. This can be done via `/etc/security/limits.conf` usingthe `as` setting to `unlimited` (note that you might have to increasethe limits for the `root` user too).=== Maximum map count checkContinuing from the previous <<max-size-virtual-memory-check,point>>, touse `mmap` effectively, Elasticsearch also requires the ability tocreate many memory-mapped areas. The maximum map count check checks thatthe kernel allows a process to have at least 262,144 memory-mapped areasand is enforced on Linux only. To pass the maximum map count check, youmust configure `vm.max_map_count` via `sysctl` to be at least `262144`.=== Client JVM checkThere are two different JVMs provided by OpenJDK-derived JVMs: theclient JVM and the server JVM. These JVMs use different compilers forproducing executable machine code from Java bytecode. The client JVM istuned for startup time and memory footprint while the server JVM istuned for maximizing performance. The difference in performance betweenthe two VMs can be substantial. The client JVM check ensures thatElasticsearch is not running inside the client JVM. To pass the clientJVM check, you must start Elasticsearch with the server VM. On modernsystems and operating systems, the server VM is thedefault. Additionally, Elasticsearch is configured by default to forcethe server VM.=== Use serial collector checkThere are various garbage collectors for the OpenJDK-derived JVMs targetingdifferent workloads. The serial collector in particular is best suited forsingle logical CPU machines or extremely small heaps, neither of which aresuitable for running Elasticsearch. Using the serial collector withElasticsearch can be devastating for performance. The serial collector checkensures that Elasticsearch is not configured to run with the serialcollector. To pass the serial collector check, you must not start Elasticsearchwith the serial collector (whether it's from the defaults for the JVM thatyou're using, or you've explicitly specified it with `-XX:+UseSerialGC`). Notethat the default JVM configuration that ship with Elasticsearch configuresElasticsearch to use the CMS collector.=== System call filter checkElasticsearch installs system call filters of various flavors depending on theoperating system (e.g., seccomp on Linux). These system call filters areinstalled to prevent the ability to execute system calls related to forking asa defense mechanism against arbitrary code execution attacks on ElasticsearchThe system call filter check ensures that if system call filters are enabled,then they were successfully installed. To pass the system call filter check youmust either fix any configuration errors on your system that prevented systemcall filters from installing (check your logs), or *at your own risk* disablesystem call filters by setting `bootstrap.system_call_filter` to `false`.=== OnError and OnOutOfMemoryError checksThe JVM options `OnError` and `OnOutOfMemoryError` enable executingarbitrary commands if the JVM encounters a fatal error (`OnError`) or an`OutOfMemoryError` (`OnOutOfMemoryError`). However, by default,Elasticsearch system call filters (seccomp) are enabled and thesefilters prevent forking. Thus, using `OnError` or `OnOutOfMemoryError`and system call filters are incompatible. The `OnError` and`OnOutOfMemoryError` checks prevent Elasticsearch from starting ifeither of these JVM options are used and system call filters areenabled. This check is always enforced. To pass this check do not enable`OnError` nor `OnOutOfMemoryError`; instead, upgrade to Java 8u92 anduse the JVM flag `ExitOnOutOfMemoryError`. While this does not have thefull capabilities of `OnError` nor `OnOutOfMemoryError`, arbitraryforking will not be supported with seccomp enabled.=== G1GC checkEarly versions of the HotSpot JVM that shipped with JDK 8 are known to haveissues that can lead to index corruption when the G1GC collector is enabled.The versions impacted are those earlier than the version of HotSpot thatshipped with JDK 8u40. The G1GC check detects these early versions of theHotSpot JVM.
 |