important-settings.asciidoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.mlockall,`bootstrap.mlockall`>>
  10. * <<network.host,`network.host`>>
  11. * <<unicast.hosts,`discovery.zen.ping.unicast.hosts`>>
  12. * <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>
  13. * <<node.max_local_storage_nodes,`node.max_local_storage_nodes`>>
  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 randomly pick a descriptive `node.name` from a
  59. list of around 3000 Marvel characters when your node starts up, but this also
  60. means that the `node.name` will change the next time the node restarts.
  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.mlockall]]
  74. === `bootstrap.mlockall`
  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.mlockall` 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 9300 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. IMPORTANT: If `discovery.zen.minimum_master_nodes` is not set when
  144. Elasticsearch is running in <<dev-vs-prod,production mode>>, an exception will
  145. be thrown which will prevent the node from starting.
  146. [float]
  147. [[node.max_local_storage_nodes]]
  148. === `node.max_local_storage_nodes`
  149. It is possible to start more than one node on the same server from the same
  150. `$ES_HOME`, just by doing the following:
  151. [source,sh]
  152. --------------------------------------------------
  153. ./bin/elasticsearch -d
  154. ./bin/elasticsearch -d
  155. --------------------------------------------------
  156. This works just fine: the data directory structure is designed to let multiple
  157. nodes coexist. However, a single instance of Elasticsearch is able to use all
  158. of the resources of a single server and it seldom makes sense to run multiple
  159. nodes on the same server in production.
  160. It is, however, possible to start more than one node on the same server by
  161. mistake and to be completely unaware that this problem exists. To prevent more
  162. than one node from sharing the same data directory, it is advisable to add the
  163. following setting:
  164. [source,yaml]
  165. --------------------------------------------------
  166. node.max_local_storage_nodes: 1
  167. --------------------------------------------------