2018-12-20 08:02:44 -05:00
|
|
|
[[modules-discovery-hosts-providers]]
|
|
|
|
=== Discovery
|
|
|
|
|
|
|
|
Discovery is the process by which the cluster formation module finds other
|
|
|
|
nodes with which to form a cluster. This process runs when you start an
|
|
|
|
Elasticsearch node or when a node believes the master node failed and continues
|
|
|
|
until the master node is found or a new master node is elected.
|
|
|
|
|
|
|
|
This process starts with a list of _seed_ addresses from one or more
|
2019-02-06 06:34:38 -05:00
|
|
|
<<built-in-hosts-providers,seed hosts providers>>, together with the addresses
|
|
|
|
of any master-eligible nodes that were in the last-known cluster. The process
|
2018-12-20 08:02:44 -05:00
|
|
|
operates in two phases: First, each node probes the seed addresses by
|
|
|
|
connecting to each address and attempting to identify the node to which it is
|
2019-09-12 06:07:34 -04:00
|
|
|
connected and to verify that it is master-eligible. Secondly, if successful, it
|
|
|
|
shares with the remote node a list of all of its known master-eligible peers
|
|
|
|
and the remote node responds with _its_ peers in turn. The node then probes all
|
|
|
|
the new nodes that it just discovered, requests their peers, and so on.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
|
|
|
If the node is not master-eligible then it continues this discovery process
|
|
|
|
until it has discovered an elected master node. If no elected master is
|
|
|
|
discovered then the node will retry after `discovery.find_peers_interval` which
|
|
|
|
defaults to `1s`.
|
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
If the node is master-eligible then it continues this discovery process until
|
|
|
|
it has either discovered an elected master node or else it has discovered
|
|
|
|
enough masterless master-eligible nodes to complete an election. If neither of
|
|
|
|
these occur quickly enough then the node will retry after
|
2018-12-20 08:02:44 -05:00
|
|
|
`discovery.find_peers_interval` which defaults to `1s`.
|
|
|
|
|
|
|
|
[[built-in-hosts-providers]]
|
2019-02-06 06:34:38 -05:00
|
|
|
==== Seed hosts providers
|
|
|
|
|
|
|
|
By default the cluster formation module offers two seed hosts providers to
|
|
|
|
configure the list of seed nodes: a _settings_-based and a _file_-based seed
|
|
|
|
hosts provider. It can be extended to support cloud environments and other
|
|
|
|
forms of seed hosts providers via {plugins}/discovery.html[discovery plugins].
|
|
|
|
Seed hosts providers are configured using the `discovery.seed_providers`
|
|
|
|
setting, which defaults to the _settings_-based hosts provider. This setting
|
|
|
|
accepts a list of different providers, allowing you to make use of multiple
|
|
|
|
ways to find the seed hosts for your cluster.
|
|
|
|
|
|
|
|
Each seed hosts provider yields the IP addresses or hostnames of the seed
|
|
|
|
nodes. If it returns any hostnames then these are resolved to IP addresses
|
|
|
|
using a DNS lookup. If a hostname resolves to multiple IP addresses then {es}
|
|
|
|
tries to find a seed node at all of these addresses. If the hosts provider does
|
2019-11-05 08:46:55 -05:00
|
|
|
not explicitly give the TCP port of the node by then, it will implicitly use the
|
2019-02-06 06:34:38 -05:00
|
|
|
first port in the port range given by `transport.profiles.default.port`, or by
|
|
|
|
`transport.port` if `transport.profiles.default.port` is not set. The number of
|
|
|
|
concurrent lookups is controlled by
|
|
|
|
`discovery.seed_resolver.max_concurrent_resolvers` which defaults to `10`, and
|
|
|
|
the timeout for each lookup is controlled by `discovery.seed_resolver.timeout`
|
|
|
|
which defaults to `5s`. Note that DNS lookups are subject to
|
|
|
|
<<networkaddress-cache-ttl,JVM DNS caching>>.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2018-12-20 08:02:44 -05:00
|
|
|
[[settings-based-hosts-provider]]
|
2019-02-06 06:34:38 -05:00
|
|
|
===== Settings-based seed hosts provider
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
The settings-based seed hosts provider uses a node setting to configure a
|
|
|
|
static list of the addresses of the seed nodes. These addresses can be given as
|
|
|
|
hostnames or IP addresses; hosts specified as hostnames are resolved to IP
|
|
|
|
addresses during each round of discovery.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
The list of hosts is set using the <<unicast.hosts,`discovery.seed_hosts`>>
|
|
|
|
static setting. For example:
|
2018-12-20 08:02:44 -05:00
|
|
|
|
|
|
|
[source,yaml]
|
|
|
|
--------------------------------------------------
|
2019-02-05 03:46:52 -05:00
|
|
|
discovery.seed_hosts:
|
2018-12-20 08:02:44 -05:00
|
|
|
- 192.168.1.10:9300
|
|
|
|
- 192.168.1.11 <1>
|
|
|
|
- seeds.mydomain.com <2>
|
|
|
|
--------------------------------------------------
|
|
|
|
<1> The port will default to `transport.profiles.default.port` and fallback to
|
|
|
|
`transport.port` if not specified.
|
2019-02-06 06:34:38 -05:00
|
|
|
<2> If a hostname resolves to multiple IP addresses, {es} will attempt to
|
|
|
|
connect to every resolved address.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2018-12-20 08:02:44 -05:00
|
|
|
[[file-based-hosts-provider]]
|
2019-02-06 06:34:38 -05:00
|
|
|
===== File-based seed hosts provider
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
The file-based seed hosts provider configures a list of hosts via an external
|
|
|
|
file. {es} reloads this file when it changes, so that the list of seed nodes
|
2018-12-20 08:02:44 -05:00
|
|
|
can change dynamically without needing to restart each node. For example, this
|
2019-02-06 06:34:38 -05:00
|
|
|
gives a convenient mechanism for an {es} instance that is run in a Docker
|
|
|
|
container to be dynamically supplied with a list of IP addresses to connect to
|
|
|
|
when those IP addresses may not be known at node startup.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2018-12-21 14:24:48 -05:00
|
|
|
To enable file-based discovery, configure the `file` hosts provider as follows
|
|
|
|
in the `elasticsearch.yml` file:
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2018-12-21 14:24:48 -05:00
|
|
|
[source,yml]
|
2018-12-20 08:02:44 -05:00
|
|
|
----------------------------------------------------------------
|
2019-02-05 03:46:52 -05:00
|
|
|
discovery.seed_providers: file
|
2018-12-20 08:02:44 -05:00
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
|
|
Then create a file at `$ES_PATH_CONF/unicast_hosts.txt` in the format described
|
2019-02-06 06:34:38 -05:00
|
|
|
below. Any time a change is made to the `unicast_hosts.txt` file the new
|
|
|
|
changes will be picked up by {es} and the new hosts list will be used.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
|
|
|
Note that the file-based discovery plugin augments the unicast hosts list in
|
2019-02-06 06:34:38 -05:00
|
|
|
`elasticsearch.yml`: if there are valid seed addresses in
|
|
|
|
`discovery.seed_hosts` then {es} uses those addresses in addition to those
|
|
|
|
supplied in `unicast_hosts.txt`.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
The `unicast_hosts.txt` file contains one node entry per line. Each node entry
|
2018-12-20 08:02:44 -05:00
|
|
|
consists of the host (host name or IP address) and an optional transport port
|
2019-02-06 06:34:38 -05:00
|
|
|
number. If the port number is specified, is must come immediately after the
|
2018-12-20 08:02:44 -05:00
|
|
|
host (on the same line) separated by a `:`. If the port number is not
|
2019-02-06 06:34:38 -05:00
|
|
|
specified, {es} will implicitly use the first port in the port range given by
|
|
|
|
`transport.profiles.default.port`, or by `transport.port` if
|
|
|
|
`transport.profiles.default.port` is not set.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
|
|
|
For example, this is an example of `unicast_hosts.txt` for a cluster with four
|
2019-02-06 06:34:38 -05:00
|
|
|
nodes that participate in discovery, some of which are not running on the
|
|
|
|
default port:
|
2018-12-20 08:02:44 -05:00
|
|
|
|
|
|
|
[source,txt]
|
|
|
|
----------------------------------------------------------------
|
|
|
|
10.10.10.5
|
|
|
|
10.10.10.6:9305
|
|
|
|
10.10.10.5:10005
|
|
|
|
# an IPv6 address
|
|
|
|
[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:9301
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
Host names are allowed instead of IP addresses and are resolved by DNS as
|
|
|
|
described above. IPv6 addresses must be given in brackets with the port, if
|
|
|
|
needed, coming after the brackets.
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2019-02-06 06:34:38 -05:00
|
|
|
You can also add comments to this file. All comments must appear on their lines
|
|
|
|
starting with `#` (i.e. comments cannot start in the middle of a line).
|
2018-12-20 08:02:44 -05:00
|
|
|
|
2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2018-12-20 08:02:44 -05:00
|
|
|
[[ec2-hosts-provider]]
|
|
|
|
===== EC2 hosts provider
|
|
|
|
|
|
|
|
The {plugins}/discovery-ec2.html[EC2 discovery plugin] adds a hosts provider
|
|
|
|
that uses the https://github.com/aws/aws-sdk-java[AWS API] to find a list of
|
|
|
|
seed nodes.
|
|
|
|
|
2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2018-12-20 08:02:44 -05:00
|
|
|
[[azure-classic-hosts-provider]]
|
|
|
|
===== Azure Classic hosts provider
|
|
|
|
|
|
|
|
The {plugins}/discovery-azure-classic.html[Azure Classic discovery plugin] adds
|
|
|
|
a hosts provider that uses the Azure Classic API find a list of seed nodes.
|
|
|
|
|
2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2018-12-20 08:02:44 -05:00
|
|
|
[[gce-hosts-provider]]
|
|
|
|
===== Google Compute Engine hosts provider
|
|
|
|
|
|
|
|
The {plugins}/discovery-gce.html[GCE discovery plugin] adds a hosts provider
|
|
|
|
that uses the GCE API find a list of seed nodes.
|