如何部署ES(Elasticsearch)集群?
我使用Docker Swarm+Compose部署我的系统,并尝试通过部署ES集群。yml:
version: '3.3'
services:
elasticsearch:
image: elasticsearch:alpine
ports:
- '9200:9200'
- '9300:9300'
command: [ elasticsearch, -E, network.host=0.0.0.0, -E, discovery.zen.ping.unicast.hosts=elasticsearch, -E, discovery.zen.minimum_master_nodes=1, -E, cluster.name=mycluster ]
networks:
- esnet1
environment:
ES_JAVA_OPTS: "-Xmx512m -Xms512m"
deploy:
mode: replicated
replicas: 2
#endpoint_mode: dnsrr
resources:
limits:
cpus: '2'
memory: 1024M
reservations:
cpus: '0.50'
memory: 512M
networks:
esnet1:
<ip>:9200/_cat/nodes?v
https://github.com/elastic/elasticsearch-docker/issues/91
假设它是Docker中的bug,它将被修复。可以,但是没有集群的ES不是ES!
在互联网上,我看到人们将不同的服务作为主服务和从服务进行部署,但这是一个笨拙的解决方案,因为ES本身决定了谁是主服务,谁不是主服务,它是否胜任。
还有一个有趣的问题:如何部署ES集群?