docker中的ElasticSearch集群始终在3节点配置中关闭一个主节点

时间:2017-08-22 03:41:20

标签: elasticsearch

我在三个docker容器中运行elasticsearch集群,docker-compose.yml如下所示。

当我运行其中任何两个时,可以设置群集哪个状态为绿色,但是当我启动第三个群集时,群集中的一个节点被强制关闭(docker容器退出)并且没有错误消息登录关闭弹性搜索节点。

节点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

1 个答案:

答案 0 :(得分:1)

这是由Mac上的docker引起的,它有内存限制(2.5G),因此它无法承受3个节点,因此其中一个节点被迫关闭。

将专用内存增加到docker引擎后,所有3个节点都启动并运行,elasticsearch集群为GREEN