Why the node is not master-eligible?

I started the ES cluster in docker following the docker-compose template (changing the es01/es02 to nes01/nes02 to avoid the name conflict).

sni@elk:~$ sudo curl http://localhost:9200/_cat/nodes?v
ip         heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.28.0.3           27          23  75    5.74    2.61     1.40 dilm      -      nes01
172.28.0.2           27          23  75    5.74    2.61     1.40 dilm      *      nes02

I thought the nes01 should be the master-eligible node with the setting of '- cluster.initial_master_nodes=es01,es02' and it should show 'm' but it was shown as '-' above. Is my understanding wrong?

When I stop the nes02 node, the nes01 is not elected as master:

sni@elk:~$ sudo curl http://localhost:9200/_cat/nodes?v
{"error":{"root_cause":[{"type":"master_not_discovered_exception","reason":null}],"type":"master_not_discovered_exception","reason":null},"status":503}sni@elk:~$

The template is here:
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/docker.html#docker-prod-cluster-composefile

docker-compose.yml:

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.4.1
    container_name: es01
    environment:
      - node.name=es01
      - discovery.seed_hosts=es02
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.4.1
    container_name: es02
    environment:
      - node.name=es02
      - discovery.seed_hosts=es01
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data
    networks:
      - esnet

volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local

networks:
  esnet:

Yes. Nodes are master-eligible by default, but you can make them master-ineligible by setting node.master: false in their config files. This is independent of the cluster.initial_master_nodes setting.

In your case, both nodes are master-eligible because they have an m in their node.role column entries (dilm). However a resilient cluster requires at least three master-eligible nodes.

Oh, thanks David, I think the 'm' was under the 'master' column, got it.

Follow up question on this is, if I stop the current master node (nes02 in this case), should nes01 node elect itself as the new master?

No, you would need three master-eligible nodes for this.

Perfect, just you described!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.