discovery.asciidoc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. [[discovery-hosts-providers]]
  2. === Discovery
  3. Discovery is the process by which the cluster formation module finds other
  4. nodes with which to form a cluster. This process runs when you start an
  5. Elasticsearch node or when a node believes the master node failed and continues
  6. until the master node is found or a new master node is elected.
  7. This process starts with a list of _seed_ addresses from one or more
  8. <<built-in-hosts-providers,seed hosts providers>>, together with the addresses
  9. of any master-eligible nodes that were in the last-known cluster. The process
  10. operates in two phases: First, each node probes the seed addresses by
  11. connecting to each address and attempting to identify the node to which it is
  12. connected and to verify that it is master-eligible. Secondly, if successful, it
  13. shares with the remote node a list of all of its known master-eligible peers
  14. and the remote node responds with _its_ peers in turn. The node then probes all
  15. the new nodes that it just discovered, requests their peers, and so on.
  16. If the node is not master-eligible then it continues this discovery process
  17. until it has discovered an elected master node. If no elected master is
  18. discovered then the node will retry after `discovery.find_peers_interval` which
  19. defaults to `1s`.
  20. If the node is master-eligible then it continues this discovery process until
  21. it has either discovered an elected master node or else it has discovered
  22. enough masterless master-eligible nodes to complete an election. If neither of
  23. these occur quickly enough then the node will retry after
  24. `discovery.find_peers_interval` which defaults to `1s`.
  25. Once a master is elected, it will normally remain as the elected master until
  26. it is deliberately stopped. It may also stop acting as the master if
  27. <<cluster-fault-detection,fault detection>> determines the cluster to be
  28. faulty. When a node stops being the elected master, it begins the discovery
  29. process again.
  30. Refer to <<discovery-troubleshooting,Troubleshooting discovery>> for
  31. troubleshooting issues with discovery.
  32. [[built-in-hosts-providers]]
  33. ==== Seed hosts providers
  34. By default the cluster formation module offers two seed hosts providers to
  35. configure the list of seed nodes: a _settings_-based and a _file_-based seed
  36. hosts provider. It can be extended to support cloud environments and other
  37. forms of seed hosts providers via {plugins}/discovery.html[discovery plugins].
  38. Seed hosts providers are configured using the `discovery.seed_providers`
  39. setting, which defaults to the _settings_-based hosts provider. This setting
  40. accepts a list of different providers, allowing you to make use of multiple
  41. ways to find the seed hosts for your cluster.
  42. Each seed hosts provider yields the IP addresses or hostnames of the seed
  43. nodes. If it returns any hostnames then these are resolved to IP addresses
  44. using a DNS lookup. If a hostname resolves to multiple IP addresses then {es}
  45. tries to find a seed node at all of these addresses. If the hosts provider does
  46. not explicitly give the TCP port of the node by then, it will implicitly use the
  47. first port in the port range given by `transport.profiles.default.port`, or by
  48. `transport.port` if `transport.profiles.default.port` is not set. The number of
  49. concurrent lookups is controlled by
  50. `discovery.seed_resolver.max_concurrent_resolvers` which defaults to `10`, and
  51. the timeout for each lookup is controlled by `discovery.seed_resolver.timeout`
  52. which defaults to `5s`. Note that DNS lookups are subject to
  53. <<networkaddress-cache-ttl,JVM DNS caching>>.
  54. [discrete]
  55. [[settings-based-hosts-provider]]
  56. ===== Settings-based seed hosts provider
  57. The settings-based seed hosts provider uses a node setting to configure a
  58. static list of the addresses of the seed nodes. These addresses can be given as
  59. hostnames or IP addresses; hosts specified as hostnames are resolved to IP
  60. addresses during each round of discovery.
  61. The list of hosts is set using the <<unicast.hosts,`discovery.seed_hosts`>>
  62. static setting. For example:
  63. [source,yaml]
  64. --------------------------------------------------
  65. discovery.seed_hosts:
  66. - 192.168.1.10:9300
  67. - 192.168.1.11 <1>
  68. - seeds.mydomain.com <2>
  69. --------------------------------------------------
  70. <1> The port will default to `transport.profiles.default.port` and fallback to
  71. `transport.port` if not specified.
  72. <2> If a hostname resolves to multiple IP addresses, {es} will attempt to
  73. connect to every resolved address.
  74. [discrete]
  75. [[file-based-hosts-provider]]
  76. ===== File-based seed hosts provider
  77. The file-based seed hosts provider configures a list of hosts via an external
  78. file. {es} reloads this file when it changes, so that the list of seed nodes
  79. can change dynamically without needing to restart each node. For example, this
  80. gives a convenient mechanism for an {es} instance that is run in a Docker
  81. container to be dynamically supplied with a list of IP addresses to connect to
  82. when those IP addresses may not be known at node startup.
  83. To enable file-based discovery, configure the `file` hosts provider as follows
  84. in the `elasticsearch.yml` file:
  85. [source,yml]
  86. ----------------------------------------------------------------
  87. discovery.seed_providers: file
  88. ----------------------------------------------------------------
  89. Then create a file at `$ES_PATH_CONF/unicast_hosts.txt` in the format described
  90. below. Any time a change is made to the `unicast_hosts.txt` file the new
  91. changes will be picked up by {es} and the new hosts list will be used.
  92. Note that the file-based discovery plugin augments the unicast hosts list in
  93. `elasticsearch.yml`: if there are valid seed addresses in
  94. `discovery.seed_hosts` then {es} uses those addresses in addition to those
  95. supplied in `unicast_hosts.txt`.
  96. The `unicast_hosts.txt` file contains one node entry per line. Each node entry
  97. consists of the host (host name or IP address) and an optional transport port
  98. number. If the port number is specified, it must come immediately after the
  99. host (on the same line) separated by a `:`. If the port number is not
  100. specified, {es} will implicitly use the first port in the port range given by
  101. `transport.profiles.default.port`, or by `transport.port` if
  102. `transport.profiles.default.port` is not set.
  103. For example, this is an example of `unicast_hosts.txt` for a cluster with four
  104. nodes that participate in discovery, some of which are not running on the
  105. default port:
  106. [source,txt]
  107. ----------------------------------------------------------------
  108. 10.10.10.5
  109. 10.10.10.6:9305
  110. 10.10.10.5:10005
  111. # an IPv6 address
  112. [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:9301
  113. ----------------------------------------------------------------
  114. Host names are allowed instead of IP addresses and are resolved by DNS as
  115. described above. IPv6 addresses must be given in brackets with the port, if
  116. needed, coming after the brackets.
  117. You can also add comments to this file. All comments must appear on their lines
  118. starting with `#` (i.e. comments cannot start in the middle of a line).
  119. [discrete]
  120. [[ec2-hosts-provider]]
  121. ===== EC2 hosts provider
  122. The {plugins}/discovery-ec2.html[EC2 discovery plugin] adds a hosts provider
  123. that uses the https://github.com/aws/aws-sdk-java[AWS API] to find a list of
  124. seed nodes.
  125. [discrete]
  126. [[azure-classic-hosts-provider]]
  127. ===== Azure Classic hosts provider
  128. The {plugins}/discovery-azure-classic.html[Azure Classic discovery plugin] adds
  129. a hosts provider that uses the Azure Classic API find a list of seed nodes.
  130. [discrete]
  131. [[gce-hosts-provider]]
  132. ===== Google Compute Engine hosts provider
  133. The {plugins}/discovery-gce.html[GCE discovery plugin] adds a hosts provider
  134. that uses the GCE API find a list of seed nodes.