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.
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.
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
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.
To resolve the MasterNotDiscoveredException, follow these steps:
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.
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.
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
After making configuration changes, restart the ElasticSearch nodes to apply the changes. Use the following command:
sudo systemctl restart elasticsearch
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.
Let Dr. Droid create custom investigation plans for your infrastructure.
Book Demo