zen.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. [[modules-discovery-zen]]
  2. === Zen Discovery
  3. Zen discovery is the built-in, default, discovery module for Elasticsearch. It
  4. provides unicast and file-based discovery, and can be extended to support cloud
  5. environments and other forms of discovery via plugins.
  6. Zen discovery is integrated with other modules, for example, all communication
  7. between nodes is done using the <<modules-transport,transport>> module.
  8. It is separated into several sub modules, which are explained below:
  9. [float]
  10. [[ping]]
  11. ==== Ping
  12. This is the process where a node uses the discovery mechanisms to find other
  13. nodes.
  14. [float]
  15. [[discovery-seed-nodes]]
  16. ==== Seed nodes
  17. Zen discovery uses a list of _seed_ nodes in order to start off the discovery
  18. process. At startup, or when electing a new master, Elasticsearch tries to
  19. connect to each seed node in its list, and holds a gossip-like conversation with
  20. them to find other nodes and to build a complete picture of the cluster. By
  21. default there are two methods for configuring the list of seed nodes: _unicast_
  22. and _file-based_. It is recommended that the list of seed nodes comprises the
  23. list of master-eligible nodes in the cluster.
  24. [float]
  25. [[unicast]]
  26. ===== Unicast
  27. Unicast discovery configures a static list of hosts for use as seed nodes.
  28. These hosts can be specified as hostnames or IP addresses; hosts specified as
  29. hostnames are resolved to IP addresses during each round of pinging. Note that
  30. if you are in an environment where DNS resolutions vary with time, you might
  31. need to adjust your <<networkaddress-cache-ttl,JVM security settings>>.
  32. The list of hosts is set using the `discovery.zen.ping.unicast.hosts` static
  33. setting. This is either an array of hosts or a comma-delimited string. Each
  34. value should be in the form of `host:port` or `host` (where `port` defaults to
  35. the setting `transport.profiles.default.port` falling back to
  36. `transport.port` if not set). Note that IPv6 hosts must be bracketed. The
  37. default for this setting is `127.0.0.1, [::1]`
  38. Additionally, the `discovery.zen.ping.unicast.resolve_timeout` configures the
  39. amount of time to wait for DNS lookups on each round of pinging. This is
  40. specified as a <<time-units, time unit>> and defaults to 5s.
  41. Unicast discovery uses the <<modules-transport,transport>> module to perform the
  42. discovery.
  43. [float]
  44. [[file-based-hosts-provider]]
  45. ===== File-based
  46. In addition to hosts provided by the static `discovery.zen.ping.unicast.hosts`
  47. setting, it is possible to provide a list of hosts via an external file.
  48. Elasticsearch reloads this file when it changes, so that the list of seed nodes
  49. can change dynamically without needing to restart each node. For example, this
  50. gives a convenient mechanism for an Elasticsearch instance that is run in a
  51. Docker container to be dynamically supplied with a list of IP addresses to
  52. connect to for Zen discovery when those IP addresses may not be known at node
  53. startup.
  54. To enable file-based discovery, configure the `file` hosts provider as follows:
  55. [source,txt]
  56. ----------------------------------------------------------------
  57. discovery.zen.hosts_provider: file
  58. ----------------------------------------------------------------
  59. Then create a file at `$ES_PATH_CONF/unicast_hosts.txt` in the format described
  60. below. Any time a change is made to the `unicast_hosts.txt` file the new
  61. changes will be picked up by Elasticsearch and the new hosts list will be used.
  62. Note that the file-based discovery plugin augments the unicast hosts list in
  63. `elasticsearch.yml`: if there are valid unicast host entries in
  64. `discovery.zen.ping.unicast.hosts` then they will be used in addition to those
  65. supplied in `unicast_hosts.txt`.
  66. The `discovery.zen.ping.unicast.resolve_timeout` setting also applies to DNS
  67. lookups for nodes specified by address via file-based discovery. This is
  68. specified as a <<time-units, time unit>> and defaults to 5s.
  69. The format of the file is to specify one node entry per line. Each node entry
  70. consists of the host (host name or IP address) and an optional transport port
  71. number. If the port number is specified, is must come immediately after the
  72. host (on the same line) separated by a `:`. If the port number is not
  73. specified, a default value of 9300 is used.
  74. For example, this is an example of `unicast_hosts.txt` for a cluster with four
  75. nodes that participate in unicast discovery, some of which are not running on
  76. the default port:
  77. [source,txt]
  78. ----------------------------------------------------------------
  79. 10.10.10.5
  80. 10.10.10.6:9305
  81. 10.10.10.5:10005
  82. # an IPv6 address
  83. [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:9301
  84. ----------------------------------------------------------------
  85. Host names are allowed instead of IP addresses (similar to
  86. `discovery.zen.ping.unicast.hosts`), and IPv6 addresses must be specified in
  87. brackets with the port coming after the brackets.
  88. It is also possible to add comments to this file. All comments must appear on
  89. their lines starting with `#` (i.e. comments cannot start in the middle of a
  90. line).
  91. [float]
  92. [[master-election]]
  93. ==== Master Election
  94. As part of the ping process a master of the cluster is either elected or joined
  95. to. This is done automatically. The `discovery.zen.ping_timeout` (which defaults
  96. to `3s`) determines how long the node will wait before deciding on starting an
  97. election or joining an existing cluster. Three pings will be sent over this
  98. timeout interval. In case where no decision can be reached after the timeout,
  99. the pinging process restarts. In slow or congested networks, three seconds
  100. might not be enough for a node to become aware of the other nodes in its
  101. environment before making an election decision. Increasing the timeout should
  102. be done with care in that case, as it will slow down the election process. Once
  103. a node decides to join an existing formed cluster, it will send a join request
  104. to the master (`discovery.zen.join_timeout`) with a timeout defaulting at 20
  105. times the ping timeout.
  106. When the master node stops or has encountered a problem, the cluster nodes start
  107. pinging again and will elect a new master. This pinging round also serves as a
  108. protection against (partial) network failures where a node may unjustly think
  109. that the master has failed. In this case the node will simply hear from other
  110. nodes about the currently active master.
  111. If `discovery.zen.master_election.ignore_non_master_pings` is `true`, pings from
  112. nodes that are not master eligible (nodes where `node.master` is `false`) are
  113. ignored during master election; the default value is `false`.
  114. Nodes can be excluded from becoming a master by setting `node.master` to
  115. `false`.
  116. The `discovery.zen.minimum_master_nodes` sets the minimum number of master
  117. eligible nodes that need to join a newly elected master in order for an election
  118. to complete and for the elected node to accept its mastership. The same setting
  119. controls the minimum number of active master eligible nodes that should be a
  120. part of any active cluster. If this requirement is not met the active master
  121. node will step down and a new master election will begin.
  122. This setting must be set to a <<minimum_master_nodes,quorum>> of your master
  123. eligible nodes. It is recommended to avoid having only two master eligible
  124. nodes, since a quorum of two is two. Therefore, a loss of either master eligible
  125. node will result in an inoperable cluster.
  126. [float]
  127. [[fault-detection]]
  128. ==== Fault Detection
  129. There are two fault detection processes running. The first is by the master, to
  130. ping all the other nodes in the cluster and verify that they are alive. And on
  131. the other end, each node pings to master to verify if its still alive or an
  132. election process needs to be initiated.
  133. The following settings control the fault detection process using the
  134. `discovery.zen.fd` prefix:
  135. [cols="<,<",options="header",]
  136. |=======================================================================
  137. |Setting |Description
  138. |`ping_interval` |How often a node gets pinged. Defaults to `1s`.
  139. |`ping_timeout` |How long to wait for a ping response, defaults to
  140. `30s`.
  141. |`ping_retries` |How many ping failures / timeouts cause a node to be
  142. considered failed. Defaults to `3`.
  143. |=======================================================================
  144. [float]
  145. ==== Cluster state updates
  146. The master node is the only node in a cluster that can make changes to the
  147. cluster state. The master node processes one cluster state update at a time,
  148. applies the required changes and publishes the updated cluster state to all the
  149. other nodes in the cluster. Each node receives the publish message, acknowledges
  150. it, but does *not* yet apply it. If the master does not receive acknowledgement
  151. from at least `discovery.zen.minimum_master_nodes` nodes within a certain time
  152. (controlled by the `discovery.zen.commit_timeout` setting and defaults to 30
  153. seconds) the cluster state change is rejected.
  154. Once enough nodes have responded, the cluster state is committed and a message
  155. will be sent to all the nodes. The nodes then proceed to apply the new cluster
  156. state to their internal state. The master node waits for all nodes to respond,
  157. up to a timeout, before going ahead processing the next updates in the queue.
  158. The `discovery.zen.publish_timeout` is set by default to 30 seconds and is
  159. measured from the moment the publishing started. Both timeout settings can be
  160. changed dynamically through the <<cluster-update-settings,cluster update
  161. settings api>>
  162. [float]
  163. [[no-master-block]]
  164. ==== No master block
  165. For the cluster to be fully operational, it must have an active master and the
  166. number of running master eligible nodes must satisfy the
  167. `discovery.zen.minimum_master_nodes` setting if set. The
  168. `discovery.zen.no_master_block` settings controls what operations should be
  169. rejected when there is no active master.
  170. The `discovery.zen.no_master_block` setting has two valid options:
  171. [horizontal]
  172. `all`:: All operations on the node--i.e. both read & writes--will be rejected.
  173. This also applies for api cluster state read or write operations, like the get
  174. index settings, put mapping and cluster state api.
  175. `write`:: (default) Write operations will be rejected. Read operations will
  176. succeed, based on the last known cluster configuration. This may result in
  177. partial reads of stale data as this node may be isolated from the rest of the
  178. cluster.
  179. The `discovery.zen.no_master_block` setting doesn't apply to nodes-based apis
  180. (for example cluster stats, node info and node stats apis). Requests to these
  181. apis will not be blocked and can run on any available node.