important-settings.asciidoc 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. [[important-settings]]
  2. == Important Elasticsearch configuration
  3. While Elasticsearch requires very little configuration, there are a number of
  4. settings which need to be configured manually and should definitely be
  5. configured before going into production.
  6. * <<path-settings,`path.data` and `path.logs`>>
  7. * <<cluster.name,`cluster.name`>>
  8. * <<node.name,`node.name`>>
  9. * <<bootstrap.memory_lock,`bootstrap.memory_lock`>>
  10. * <<network.host,`network.host`>>
  11. * <<unicast.hosts,`discovery.zen.ping.unicast.hosts`>>
  12. * <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>
  13. * <<heap-dump-path,JVM heap dump path>>
  14. [float]
  15. [[path-settings]]
  16. === `path.data` and `path.logs`
  17. If you are using the `.zip` or `.tar.gz` archives, the `data` and `logs`
  18. directories are sub-folders of `$ES_HOME`. If these important folders are
  19. left in their default locations, there is a high risk of them being deleted
  20. while upgrading Elasticsearch to a new version.
  21. In production use, you will almost certainly want to change the locations of
  22. the data and log folder:
  23. [source,yaml]
  24. --------------------------------------------------
  25. path:
  26. logs: /var/log/elasticsearch
  27. data: /var/data/elasticsearch
  28. --------------------------------------------------
  29. The RPM and Debian distributions already use custom paths for `data` and
  30. `logs`.
  31. The `path.data` settings can be set to multiple paths, in which case all paths
  32. will be used to store data (although the files belonging to a single shard
  33. will all be stored on the same data path):
  34. [source,yaml]
  35. --------------------------------------------------
  36. path:
  37. data:
  38. - /mnt/elasticsearch_1
  39. - /mnt/elasticsearch_2
  40. - /mnt/elasticsearch_3
  41. --------------------------------------------------
  42. [float]
  43. [[cluster.name]]
  44. === `cluster.name`
  45. A node can only join a cluster when it shares its `cluster.name` with all the
  46. other nodes in the cluster. The default name is `elasticsearch`, but you
  47. should change it to an appropriate name which describes the purpose of the
  48. cluster.
  49. [source,yaml]
  50. --------------------------------------------------
  51. cluster.name: logging-prod
  52. --------------------------------------------------
  53. Make sure that you don't reuse the same cluster names in different
  54. environments, otherwise you might end up with nodes joining the wrong cluster.
  55. [float]
  56. [[node.name]]
  57. === `node.name`
  58. By default, Elasticsearch will take the 7 first character of the randomly generated uuid used as the node id.
  59. Note that the node id is persisted and does not change when a node restarts and therefore the default node name
  60. will also not change.
  61. It is worth configuring a more meaningful name which will also have the
  62. advantage of persisting after restarting the node:
  63. [source,yaml]
  64. --------------------------------------------------
  65. node.name: prod-data-2
  66. --------------------------------------------------
  67. The `node.name` can also be set to the server's HOSTNAME as follows:
  68. [source,yaml]
  69. --------------------------------------------------
  70. node.name: ${HOSTNAME}
  71. --------------------------------------------------
  72. [float]
  73. [[bootstrap.memory_lock]]
  74. === `bootstrap.memory_lock`
  75. It is vitally important to the health of your node that none of the JVM is
  76. ever swapped out to disk. One way of achieving that is set the
  77. `bootstrap.memory_lock` setting to `true`.
  78. For this setting to have effect, other system settings need to be configured
  79. first. See <<mlockall>> for more details about how to set up memory locking
  80. correctly.
  81. [float]
  82. [[network.host]]
  83. === `network.host`
  84. By default, Elasticsearch binds to loopback addresses only -- e.g. `127.0.0.1`
  85. and `[::1]`. This is sufficient to run a single development node on a server.
  86. TIP: In fact, more than one node can be started from the same `$ES_HOME` location
  87. on a single node. This can be useful for testing Elasticsearch's ability to
  88. form clusters, but it is not a configuration recommended for production.
  89. In order to communicate and to form a cluster with nodes on other servers,
  90. your node will need to bind to a non-loopback address. While there are many
  91. <<modules-network,network settings>>, usually all you need to configure is
  92. `network.host`:
  93. [source,yaml]
  94. --------------------------------------------------
  95. network.host: 192.168.1.10
  96. --------------------------------------------------
  97. The `network.host` setting also understands some special values such as
  98. `_local_`, `_site_`, `_global_` and modifiers like `:ip4` and `:ip6`, details
  99. of which can be found in <<network-interface-values>>.
  100. IMPORTANT: As soon you provide a custom setting for `network.host`,
  101. Elasticsearch assumes that you are moving from development mode to production
  102. mode, and upgrades a number of system startup checks from warnings to
  103. exceptions. See <<dev-vs-prod>> for more information.
  104. [float]
  105. [[unicast.hosts]]
  106. === `discovery.zen.ping.unicast.hosts`
  107. Out of the box, without any network configuration, Elasticsearch will bind to
  108. the available loopback addresses and will scan ports 9300 to 9305 to try to
  109. connect to other nodes running on the same server. This provides an auto-
  110. clustering experience without having to do any configuration.
  111. When the moment comes to form a cluster with nodes on other servers, you have
  112. to provide a seed list of other nodes in the cluster that are likely to be
  113. live and contactable. This can be specified as follows:
  114. [source,yaml]
  115. --------------------------------------------------
  116. discovery.zen.ping.unicast.hosts:
  117. - 192.168.1.10:9300
  118. - 192.168.1.11 <1>
  119. - seeds.mydomain.com <2>
  120. --------------------------------------------------
  121. <1> The port will default to `transport.profiles.default.port` and fallback to `transport.tcp.port` if not specified.
  122. <2> A hostname that resolves to multiple IP addresses will try all resolved addresses.
  123. [float]
  124. [[minimum_master_nodes]]
  125. === `discovery.zen.minimum_master_nodes`
  126. To prevent data loss, it is vital to configure the
  127. `discovery.zen.minimum_master_nodes` setting so that each master-eligible node
  128. knows the _minimum number of master-eligible nodes_ that must be visible in
  129. order to form a cluster.
  130. Without this setting, a cluster that suffers a network failure is at risk of
  131. having the cluster split into two independent clusters -- a split brain --
  132. which will lead to data loss. A more detailed explanation is provided
  133. in <<split-brain>>.
  134. To avoid a split brain, this setting should be set to a _quorum_ of master-
  135. eligible nodes:
  136. (master_eligible_nodes / 2) + 1
  137. In other words, if there are three master-eligible nodes, then minimum master
  138. nodes should be set to `(3 / 2) + 1` or `2`:
  139. [source,yaml]
  140. --------------------------------------------------
  141. discovery.zen.minimum_master_nodes: 2
  142. --------------------------------------------------
  143. [float]
  144. [[heap-dump-path]]
  145. === JVM heap dump path
  146. The <<rpm,RPM>> and <<deb,Debian>> package distributions default to configuring
  147. the JVM to dump the heap on out of memory exceptions to
  148. `/var/lib/elasticsearch`. If this path is not suitable for storing heap dumps,
  149. you should modify the entry `-XX:HeapDumpPath=/var/lib/elasticsearch` in
  150. <<jvm-options,`jvm.options`>> to an alternate path. If you specify a filename
  151. instead of a directory, the JVM will repeatedly use the same file; this is one
  152. mechanism for preventing heap dumps from accumulating in the heap dump path.
  153. Alternatively, you can configure a scheduled task via your OS to remove heap
  154. dumps that are older than a configured age.
  155. Note that the archive distributions do not configure the heap dump path by
  156. default. Instead, the JVM will default to dumping to the working directory for
  157. the Elasticsearch process. If you wish to configure a heap dump path, you should
  158. modify the entry `#-XX:HeapDumpPath=/heap/dump/path` in
  159. <<jvm-options,`jvm.options`>> to remove the comment marker `#` and to specify an
  160. actual path.