Docker 容器集群中的 Elasticsearch [英] Elasticsearch in Docker container cluster
问题描述
我想在 2 个不同的主机上运行 2 个 Elasticsearch 实例.
I want to run 2 instances of Elasticsearch on 2 different hosts.
我已经基于 Ubuntu 14.04 和 1.3.2 版本的 Elasticsearch 构建了自己的 Docker 镜像.如果我在 1 台主机上运行 2 个 ES 容器,则每个实例都可以看到另一个实例并与之通信;但是当我在 2 个不同的主机上运行 2 个 ES 实例时,它不起作用.容器的9300端口绑定到主机的9300端口.
I have built my own Docker image based on Ubuntu 14.04 and the 1.3.2 version of Elasticsearch. If I run 2 ES containers on 1 host, each instance can see and communicate with the other; but when I run 2 instances of ES on 2 different hosts, it didn't work. The 9300 port of the container is bind to the 9300 host's port.
可以用我的配置创建ES集群吗?
Is it possible to create an ES cluster with my configuration?
推荐答案
使用 docker-compose 比在命令行中手动运行要容易得多:
Using docker-compose is much easier than running it manually in command line:
elasticsearch_master:
image: elasticsearch:latest
command: "elasticsearch -Des.cluster.name=workagram -Des.node.master=true -Des.node.data=false"
environment:
- ES_HEAP_SIZE=512m
ports:
- "9200:9200"
- "9300:9300"
elasticsearch1:
image: elasticsearch:latest
command: "elasticsearch -Des.cluster.name=workagram -Des.discovery.zen.ping.unicast.hosts=elasticsearch_master"
links:
- elasticsearch_master
volumes:
- "/opt/elasticsearch/data"
environment:
- ES_HEAP_SIZE=512m
elasticsearch2:
image: elasticsearch:latest
command: "elasticsearch -Des.cluster.name=workagram -Des.discovery.zen.ping.unicast.hosts=elasticsearch_master"
links:
- elasticsearch_master
volumes:
- "/opt/elasticsearch/data"
environment:
- ES_HEAP_SIZE=512m
这篇关于Docker 容器集群中的 Elasticsearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!