我有一个docker compose正在努力创建一个具有1个主节点和2个数据节点的弹性搜索节点集群,如下所示,但我想知道如何扩展它以添加更多主节点,因为仍有单点如果主节点发生故障,则使用此设置失败。
更具体地说,第二主节点如何与主机和主机进行交互。应用程序使用它?您是否必须绑定到主机上的另一个端口以用于第二个主节点?然后应用程序是否必须通过负载均衡器来处理任何一个主要噪声下降的情况?
elasticsearch_master:
image: elasticsearch:latest
command: "elasticsearch -Des.cluster.name=vi -Des.node.master=true -Des.node.data=false"
ports:
- "9200:9200"
- "9300:9300"
elasticsearch1:
image: elasticsearch:latest
command: "elasticsearch -Des.cluster.name=vi -Des.discovery.zen.ping.unicast.hosts=elasticsearch_master"
links:
- elasticsearch_master
volumes:
- "~/esdata:/usr/share/elasticsearch/data"
elasticsearch2:
image: elasticsearch:latest
command: "elasticsearch -Des.cluster.name=vi -Des.discovery.zen.ping.unicast.hosts=elasticsearch_master"
links:
- elasticsearch_master
volumes:
- "~/esdata:/usr/share/elasticsearch/data"
答案 0 :(得分:1)
我知道我们的做法不一样,但这是一个对我有用的代码示例。
services:
esmaster1:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: esmaster1
environment:
- cluster.name=es_cluster
- bootstrap.memory_lock=true
- http.cors.enabled=true
- "http.cors.allow-origin=*"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
- "node.master=true"
- "node.data=true"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/home/ruan/workspace/docker/elasticsearch/data
esmaster2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: esmaster2
environment:
- cluster.name=es_cluster
- bootstrap.memory_lock=true
- http.cors.enabled=true
- "http.cors.allow-origin=*"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
- "node.master=true"
- "node.data=true"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/home/ruan/workspace/docker/elasticsearch/data
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: elasticsearch1
environment:
- cluster.name=es_cluster
- bootstrap.memory_lock=true
- http.cors.enabled=true
- "http.cors.allow-origin=*"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
- "node.master=false"
- "node.data=true"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata3:/home/ruan/workspace/docker/elasticsearch/data
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: elasticsearch2
environment:
- cluster.name=es_cluster
- bootstrap.memory_lock=true
- http.cors.enabled=true
- "http.cors.allow-origin=*"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=esmaster1,esmaster2"
- "node.master=false"
- "node.data=true"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata4:/home/ruan/workspace/docker/elasticsearch/data
volumes:
esdata1:
driver: local
esdata2:
driver: local
esdata3:
driver: local
esdata4:
driver: local
如果主节点去世,则第二个接管,成为主节点并处理集群。如果要使用Kibana(或任何其他可视化工具),则还应该向集群添加另一个Elasticsearch实例以处理该连接。这个新实例不必是主节点,数据节点或摄取节点。
我希望这会有所帮助!