我想创建3个节点的elasticsearch集群,其中包含1个主节点和2个工作节点。 ES v6和Swarm v1.18。有人可以帮忙吗?
答案 0 :(得分:0)
您需要使用3个服务创建一个Elasticsearch堆栈。
sudo nano elasticsearch-swarm.yaml
version: '3.7'
services:
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
hostname: elasticsearch1
volumes:
- elasticsearch1-data:/usr/share/elasticsearch/data
environment:
- cluster.name=elasticsearch-cluster
- "discovery.zen.ping.unicast.hosts=tasks.elasticsearch1"
- "network.host=0.0.0.0"
- "node.max_local_storage_nodes=2"
ports:
- "9200:9200"
networks:
- elasticsearch_distributed
deploy:
replicas: 3
restart_policy:
delay: 30s
max_attempts: 10
window: 120s
volumes:
elasticsearch1-data:
networks:
elasticsearch_distributed:
driver: overlay
sudo docker stack deploy --compose-file=elasticsearch-swarm.yaml elasticsearch
此命令将在同一集群中创建3个Elasticsearch服务器副本。
如果收到错误消息,提示您没有足够的 max_map_count ,并要求设置至少 262144 ,请执行以下步骤:
sudo nano /etc/sysctl.conf
vm.max_map_count=262144
sudo sysctl -w vm.max_map_count=262144