test123
test123

Reputation: 14175

master_not_discovered_exception ElasticSearch single node

I am trying to setup elasticsearch on a single host. Here is how my configuration looks like:

elasticsearch.yml

node.name: ${HOSTNAME}

network.host: _site_, _local_
http.port: 9200
transport.tcp.port: 9300
cluster.name: "test_cluster"
node.local: true

kibana.yml

server.host: 0.0.0.0
elasticsearch.url: http://localhost:9200

On following command:

curl -XGET 'localhost:9200/_cluster/health?pretty'

I get following message:

{
  "error" : {
  "root_cause" : [
   {
      "type" : "master_not_discovered_exception",
      "reason" : null
   }
  ],
  "type" : "master_not_discovered_exception",
  "reason" : null
},
 "status" : 503
}

In log file I see following message:

not enough master nodes discovered during pinging (found [[]], but needed [-1]), pinging again

Could someone please point me right direction here?

Upvotes: 12

Views: 16382

Answers (6)

Prabhat Singh
Prabhat Singh

Reputation: 1555

Following changes in eleasticsearch.yml worked for me

Node

node.name: node-1

Paths

path.data: /var/lib/elasticsearch

path.logs: /var/log/elasticsearch

Network

network.host: 0.0.0.0

http.port: 9200

Discovery

discovery.seed_hosts: "127.0.0.1:9300"

cluster.initial_master_nodes: ["node-1"]

Steps:

  1. sudo systemctl stop elasticsearch.service
  2. sudo nano /etc/elasticsearch/elasticsearch.yml
  3. Apply above changes, save and close the editor.
  4. sudo /bin/systemctl daemon-reload
  5. sudo /bin/systemctl enable elasticsearch.service
  6. sudo systemctl start elasticsearch.service

NOTE: elasticsearch7 is used with ubuntu 20.04, it should work with other versions as well

Upvotes: 4

Julien Le Coupanec
Julien Le Coupanec

Reputation: 7988

On my side, after installing ES 7+, I had to set node-1 as a master-eligible node in the new cluster.

sudo nano /etc/elasticsearch/elasticsearch.yml

cluster.initial_master_nodes: ["node-1"]

Upvotes: 1

James T Snell
James T Snell

Reputation: 1678

I spent days (sigh) on basically this. I was trying to upgrade my single node cluster from 6.x es to 7.x, and I kept dying on the hill of "master_not_discovered_exception".

What finally solved it for me was examining a completely fresh install of 7.x.

For my single-node cluster, my /etc/elasticsearch/elasticsearch.yml needed the line:

discovery.type: single-node

I hope that saves someone else from spending days like I did. In my defence, I'm very new to es.

Upvotes: 34

Saleh
Saleh

Reputation: 1931

According to this link, for the very first time you should set initial_master_nodes config like this in /etc/elasticsearch/elasticsearch.yml:

node.name: "salehnode"

cluster.initial_master_nodes: 
   - salehnode

Upvotes: 1

user8638168
user8638168

Reputation: 1

You can try this in your elasticsearch.yml:

discovery.zen.minimum_master_nodes: 1

I think ES will always find discovery.zen.ping.unicast.hosts until it finds nodes of count equal to minimum_master_nodes.

Upvotes: 0

Nikunj Bhalla
Nikunj Bhalla

Reputation: 9

First I dont think you need network.host setting for this.

In your log it is trying to get a master, but result is 0

Can you try setting properties like:

node.master: true
node.data:true

Also can you please put more logs here, if it doesnt work

Upvotes: 0

Related Questions