Jimmy Shen
Jimmy Shen

Reputation: 240

ElasticSearch cluster in docker always shut down one master in 3 node configuration

I run elasticsearch cluster in three docker containers, docker-compose.yml as below.

When I run whichever two of them, the cluster can be set up which status is GREEN, but when I start the third one, one of node in the cluster is forced shutdown (the docker container quits) and no error message is logged in the shutdown elasticsearch node.

node 1 docker-compose.yml:

version: '2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.1
container_name: elasticsearch1
environment:
  - cluster.name=MoquiElasticSearch
  - bootstrap.memory_lock=true
  - discovery.zen.minimum_master_nodes=2
  - xpack.security.enabled=false
  - transport.publish_host=192.168.2.101
  - http.publish_host=192.168.2.101
  - discovery.zen.ping.unicast.hosts=192.168.2.101:9301,192.168.2.101:9302
  - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
  - TZ=Asia/Shanghai
ulimits:
  memlock:
    soft: -1
    hard: -1
mem_limit: 1g
ports:
  - 9200:9200
  - 9300:9300

node 2 docker-compose.yml

version: '2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.1
container_name: elasticsearch2
environment:
  - cluster.name=MoquiElasticSearch
  - bootstrap.memory_lock=true
  - discovery.zen.minimum_master_nodes=2
  - xpack.security.enabled=false
  - transport.publish_host=192.168.2.101
  - transport.publish_port=9301
  - transport.tcp.port=9301
  - http.publish_host=192.168.2.101
  - http.publish_port=9201
  - http.port=9201
  - discovery.zen.ping.unicast.hosts=192.168.2.101:9300,192.168.2.101:9302
  - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
  - TZ=Asia/Shanghai
ulimits:
  memlock:
    soft: -1
    hard: -1
mem_limit: 1g
ports:
  - 9201:9201
  - 9301:9301

node 3 docker-compose.yml

version: '2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.1
container_name: elasticsearch3
environment:
  - cluster.name=MoquiElasticSearch
  - bootstrap.memory_lock=true
  - discovery.zen.minimum_master_nodes=2
  - xpack.security.enabled=false
  - transport.publish_host=192.168.2.101
  - transport.publish_port=9302
  - transport.tcp.port=9302
  - http.publish_host=192.168.2.101
  - http.publish_port=9202
  - http.port=9202
  - discovery.zen.ping.unicast.hosts=192.168.2.101:9300,192.168.2.101:9301
  - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
  - TZ=Asia/Shanghai
ulimits:
  memlock:
    soft: -1
    hard: -1
mem_limit: 1g
ports:
  - 9202:9202
  - 9302:9302

Upvotes: 2

Views: 1407

Answers (1)

Jimmy Shen
Jimmy Shen

Reputation: 240

This is caused by the docker on Mac that it has memory limit (was 2.5G) so that it can't afford 3 nodes, so one of them is forced to shut down.

After increase the dedicated memory to docker engine, all 3 nodes are up and running and elasticsearch cluster is GREEN

Upvotes: 1

Related Questions