Bootstrapping a cluster

edit

Starting an Elasticsearch cluster for the very first time requires the initial set of master-eligible nodes to be explicitly defined on one or more of the master-eligible nodes in the cluster. This is known as cluster bootstrapping. This is only required the first time a cluster starts up: nodes that have already joined a cluster store this information in their data folder for use in a full cluster restart, and freshly-started nodes that are joining a running cluster obtain this information from the cluster’s elected master.

The initial set of master-eligible nodes is defined in the cluster.initial_master_nodes setting. This should be set to a list containing one of the following items for each master-eligible node:

  • The node name of the node.
  • The node’s hostname if node.name is not set, because node.name defaults to the node’s hostname. You must use either the fully-qualified hostname or the bare hostname depending on your system configuration.
  • The IP address of the node’s transport publish address, if it is not possible to use the node.name of the node. This is normally the IP address to which network.host resolves but this can be overridden.
  • The IP address and port of the node’s publish address, in the form IP:PORT, if it is not possible to use the node.name of the node and there are multiple nodes sharing a single IP address.

When you start a master-eligible node, you can provide this setting on the command line or in the elasticsearch.yml file. After the cluster has formed, remove this setting from each node’s configuration. It should not be set for master-ineligible nodes, master-eligible nodes joining an existing cluster, or when restarting one or more nodes.

It is technically sufficient to set cluster.initial_master_nodes on a single master-eligible node in the cluster, and only to mention that single node in the setting’s value, but this provides no fault tolerance before the cluster has fully formed. It is therefore better to bootstrap using at least three master-eligible nodes, each with a cluster.initial_master_nodes setting containing all three nodes.

You must set cluster.initial_master_nodes to the same list of nodes on each node on which it is set in order to be sure that only a single cluster forms during bootstrapping and therefore to avoid the risk of data loss.

For a cluster with 3 master-eligible nodes (with node names master-a, master-b and master-c) the configuration will look as follows:

cluster.initial_master_nodes:
  - master-a
  - master-b
  - master-c

Like all node settings, it is also possible to specify the initial set of master nodes on the command-line that is used to start Elasticsearch:

bin/elasticsearch -E cluster.initial_master_nodes=master-a,master-b,master-c

Choosing a cluster name

edit

The cluster.name setting enables you to create multiple clusters which are separated from each other. Nodes verify that they agree on their cluster name when they first connect to each other, and Elasticsearch will only form a cluster from nodes that all have the same cluster name. The default value for the cluster name is elasticsearch, but it is recommended to change this to reflect the logical name of the cluster.

Auto-bootstrapping in development mode

edit

By default each node will automatically bootstrap itself into a single-node cluster the first time it starts. If any of the following settings are configured then auto-bootstrapping will not take place:

  • discovery.seed_providers
  • discovery.seed_hosts
  • cluster.initial_master_nodes

To add a new node into an existing cluster, configure discovery.seed_hosts or other relevant discovery settings so that the new node can discover the existing master-eligible nodes in the cluster. To bootstrap a new multi-node cluster, configure cluster.initial_master_nodes as described in the section on cluster bootstrapping as well as discovery.seed_hosts or other relevant discovery settings.