Elasticsearch cluster.initial_master_nodes Setting

The cluster.initial_master_nodes setting is a crucial configuration parameter in Elasticsearch that specifies the initial set of master-eligible nodes for cluster bootstrap. It plays a vital role in the cluster formation process, especially when starting a new cluster for the first time.

  • Default value: No default value; must be explicitly set for new clusters
  • Possible values: A list of node names or IP addresses
  • Recommendation: Set this value when bootstrapping a new cluster with multiple nodes

This setting is used to determine the initial set of master-eligible nodes that should join to form a new cluster. It helps prevent the "split-brain" problem by ensuring that only one cluster forms, even if multiple master-eligible nodes start independently.

Example and Effects

cluster.initial_master_nodes:
  - node-1
  - node-2
  - node-3

In this example, we specify three nodes that are eligible to become the initial master. When starting a new cluster, you would set this on all master-eligible nodes.

You must set this when bootstrapping a new multi-node cluster to ensure proper cluster formation.

Proper configuration ensures that the cluster forms correctly and prevents split-brain scenarios during initial cluster startup.

Common Issues and Misuses

  • Forgetting to remove the setting after the cluster is formed
  • Incorrectly specifying node names or IP addresses
  • Using this setting on an already formed cluster

Do's and Don'ts

Do's:

  • Set this on all master-eligible nodes when bootstrapping a new cluster
  • Use consistent values across all nodes
  • Remove the setting after the cluster has formed successfully

Don'ts:

  • Don't use this setting on an existing cluster
  • Don't leave this setting in the configuration after initial cluster formation
  • Don't use it for adding new nodes to an existing cluster

Frequently Asked Questions

Q: Do I need to set cluster.initial_master_nodes for a single-node cluster?
A: No, it's not necessary for single-node clusters. Elasticsearch can form a cluster automatically in this case.

Q: How many nodes should I list in cluster.initial_master_nodes?
A: It's recommended to list all master-eligible nodes in your initial cluster setup. For optimal fault tolerance, use an odd number of nodes, typically 3 or 5.

Q: Can I use IP addresses instead of node names in cluster.initial_master_nodes?
A: Yes, you can use either node names or IP addresses. However, using node names is generally preferred for clarity and flexibility.

Q: What happens if I don't set cluster.initial_master_nodes in a multi-node cluster?
A: Without this setting, master-eligible nodes may not be able to discover each other and form a cluster, leading to startup failures or multiple independent clusters.

Q: Should I keep cluster.initial_master_nodes in my configuration after the cluster is formed?
A: No, you should remove this setting after the cluster has successfully formed. It's only needed for the initial bootstrap process.

Pulse - Elasticsearch Operations Done Right

Stop googling errors and staring at dashboards.

Free Trial

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.