curious1
curious1

Reputation: 14737

How can I know which nodes in a cluster are actual master nodes?

I use ES 2.2.0. and have a cluster of nodes. I would like to know which node or nodes are actual master ones. How can I do that?

I tried the following ways:

curl http://my_computer:9200/_cluster/state?pretty
curl http://my_computer:9200/_nodes?pretty

and I was unable to find which node is master.

Upvotes: 8

Views: 11862

Answers (4)

serv-inc
serv-inc

Reputation: 38297

As written, _cat/master shows the master node.

To get the master-eligible nodes, you can add the role parameter to _cat/nodes, such as https://localhost:9200/_cat/nodes?v&h=id,ip,port,v,m,r

The output is like

# ip            heap.percent ram.percent cpu load_1m load_5m load_15m node.role   master name
node1                27            76    0    0.05    0.04     0.11 cdfhilmrstw   -      node1
node2                17            80    1    0.02    0.06     0.12 cdfhilmrstw   *      node2
node3                35            72    0    0.06    0.13     0.16 cdfhilmrstw   -      node3

If the character m is contained in the roles,

which it's here: cdfhilmrstw

it's master-eligible.

Upvotes: 0

CodeWalker
CodeWalker

Reputation: 2398

With respect to Elasticsearch 6.6, this is how you can get the id of the master_node

curl -X GET "192.168.0.1:9200/_cluster/state/master_node?pretty"

{
  "cluster_name" : "logbox",
  "compressed_size_in_bytes" : 11150,
  "cluster_uuid" : "eSpyTgXbTJirTjWtPW_HYQ",
  "master_node" : "R8Gn9Km0T92H9D7TXGpX4k"
}

Upvotes: 2

Val
Val

Reputation: 217554

There is only ever one single master in a cluster, chosen among the set of master-eligible nodes.

You can either run the /_cat/master command or the /_cat/nodes command.

The former will yield something like this

% curl 'localhost:9200/_cat/master?v'
id                     ip            node
Ntgn2DcuTjGuXlhKDUD4vA 192.168.56.30 Solarr

and the latter command will yield the list of nodes with the master column (m for short). Nodes with m are master-eligible nodes and the one with the * is the current master.

% curl 192.168.56.10:9200/_cat/nodes?v&h=id,ip,port,v,m
id   ip            port version m
pLSN 192.168.56.30 9300 2.2.0   m
k0zy 192.168.56.10 9300 2.2.0   m
6Tyi 192.168.56.20 9300 2.2.0   *

Upvotes: 10

sinneduy
sinneduy

Reputation: 137

It isn't nodes that are primary, but shards. If you check out https://www.elastic.co/guide/en/elasticsearch/reference/2.2/cat-shards.html

You can try something like: http://my_computer:9200/_cat/shards?v

Upvotes: 2

Related Questions