Debug Your Infrastructure

Get Instant Solutions for Kubernetes, Databases, Docker and more

AWS CloudWatch
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Pod Stuck in CrashLoopBackOff
Database connection timeout
Docker Container won't Start
Kubernetes ingress not working
Redis connection refused
CI/CD pipeline failing

ElasticSearch MasterNotDiscoveredException

The cluster is unable to elect a master node, often due to network issues or misconfiguration.

Understanding ElasticSearch

ElasticSearch is a powerful open-source search and analytics engine, designed for scalability and real-time data retrieval. It is commonly used for log and event data analysis, full-text search, and more. ElasticSearch operates as a distributed system, meaning it can scale horizontally by adding more nodes to the cluster.

Identifying the Symptom: MasterNotDiscoveredException

One of the common issues encountered in ElasticSearch is the MasterNotDiscoveredException. This error indicates that the cluster is unable to elect a master node. The master node is crucial for managing the cluster state and coordinating operations across nodes.

What You Observe

When this exception occurs, you may notice that your cluster is not functioning correctly. Queries may fail, and the cluster health status may be red or yellow. The logs will typically contain entries similar to:

[WARN ][o.e.c.c.ClusterFormationFailureHelper] [node-1] master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster

Delving into the Issue

The MasterNotDiscoveredException usually arises due to network issues or misconfiguration in the cluster settings. ElasticSearch requires a majority of master-eligible nodes to be available to elect a master. If nodes cannot communicate due to network partitions or incorrect settings, the election process fails.

Common Causes

  • Network partitions preventing nodes from communicating.
  • Misconfigured discovery settings.
  • Insufficient number of master-eligible nodes.

Steps to Resolve the Issue

To resolve the MasterNotDiscoveredException, follow these steps:

1. Verify Network Connectivity

Ensure that all nodes can communicate with each other. Check firewall settings and network configurations. Use tools like ping or telnet to test connectivity between nodes.

2. Check Discovery Settings

Review the elasticsearch.yml configuration file on each node. Ensure that the discovery.seed_hosts and cluster.initial_master_nodes settings are correctly configured. For more details, refer to the ElasticSearch Discovery Settings documentation.

3. Ensure Sufficient Master-Eligible Nodes

ElasticSearch requires a majority of master-eligible nodes to elect a master. If you have a small cluster, ensure that at least three nodes are configured as master-eligible. This can be set in the elasticsearch.yml file:

node.master: true

4. Restart Nodes

After making configuration changes, restart the ElasticSearch nodes to apply the changes. Use the following command:

sudo systemctl restart elasticsearch

Conclusion

By ensuring proper network connectivity, verifying discovery settings, and maintaining a sufficient number of master-eligible nodes, you can resolve the MasterNotDiscoveredException and restore your ElasticSearch cluster to a healthy state. For further assistance, consider visiting the ElasticSearch Discuss Forum for community support.

Evaluating engineering tools? Get the comparison in Google Sheets

(Perfect for making buy/build decisions or internal reviews.)

Most-used commands
Your email is safe thing.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid