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: