Created
November 19, 2019 13:41
-
-
Save jakubhajek/73b36e88a9a85a11b56aa71294e6ef90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: Jakub Hajek, [email protected] | |
# | |
# docker stack deploy -c stack-elastic.yml elastic | |
# | |
# The stack creates Elasticsearch cluster consiting of | |
# - 3 dedicated master nodes in order to keep quorum | |
# - 4 dedicated data nodes to manage CRUD, | |
# | |
# Docker compose file to easily deploy Elasticsearch cluster 7.x on Docker Swarm cluster. | |
# Make sure to tune your VM to run Elasticsearch cluster by executing on each server: | |
# sudo sysctl -w vm.max_map_count=262144 | |
# add --default-ulimit memlock=-1 to Dockerd | |
# You can manage that by executing this command on each server consiting Swarm cluter: | |
# | |
# sudo "sed -i '/ExecStart=\/usr\/bin\/dockerd/ s/$/\ --default-ulimit memlock=-1/' /etc/systemd/system/docker.service.d/10-machine.conf" | |
version: "3.7" | |
x-default-logs: &default-opts | |
logging: | |
options: | |
max-size: "1m" | |
x-master-opts: &master | |
ES_JAVA_OPTS: "-Xmx2g -Xms2g" | |
discovery.seed_resolver.timeout: 60s | |
discovery.seed_hosts: master1,master2,master3 | |
cluster.initial_master_nodes: master1,master2,master3 | |
cluster.name: "es-cluster" | |
network.host: 0.0.0.0 | |
node.master: "true" | |
node.data: "false" | |
node.ingest: "false" | |
x-data-opts: &data | |
ES_JAVA_OPTS: "-Xmx2g -Xms2g" | |
discovery.seed_resolver.timeout: 60s | |
discovery.seed_hosts: master1,master2,master3 | |
cluster.initial_master_nodes: master1,master2,master3 | |
cluster.name: "es-cluster" | |
network.host: 0.0.0.0 | |
node.master: "false" | |
node.data: "true" | |
node.ingest: "false" | |
services: | |
master1: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *master | |
node.name: "master1" | |
networks: | |
esnet: | |
aliases: | |
- master1 | |
volumes: | |
- esmaster1:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.master1 == true] | |
endpoint_mode: dnsrr | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
master2: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *master | |
node.name: "master2" | |
networks: | |
esnet: | |
aliases: | |
- master2 | |
volumes: | |
- esmaster2:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.master2 == true] | |
endpoint_mode: dnsrr | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
master3: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *master | |
node.name: "master3" | |
networks: | |
esnet: | |
aliases: | |
- master3 | |
volumes: | |
- esmaster3:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.master3 == true] | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
data1: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *data | |
node.name: "data1" | |
healthcheck: | |
test: curl -fs http://localhost:9200/_cat/health || exit 1 | |
interval: 30s | |
timeout: 5s | |
retries: 3 | |
start_period: 45s | |
networks: | |
esnet: | |
aliases: | |
- data1 | |
volumes: | |
- esdata1:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.data1 == true] | |
endpoint_mode: dnsrr | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
data2: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *data | |
node.name: "data2" | |
healthcheck: | |
test: curl -fs http://localhost:9200/_cat/health || exit 1 | |
interval: 30s | |
timeout: 5s | |
retries: 3 | |
start_period: 45s | |
networks: | |
esnet: | |
aliases: | |
- data2 | |
volumes: | |
- esdata2:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.data2 == true] | |
endpoint_mode: dnsrr | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
data3: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *data | |
node.name: "data3" | |
networks: | |
esnet: | |
aliases: | |
- data3 | |
volumes: | |
- esdata3:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.data3 == true] | |
endpoint_mode: dnsrr | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
data4: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 | |
environment: | |
<<: *data | |
node.name: "data4" | |
networks: | |
esnet: | |
aliases: | |
- data4 | |
volumes: | |
- esdata4:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: [node.labels.data4 == true] | |
endpoint_mode: dnsrr | |
mode: "replicated" | |
replicas: 1 | |
resources: | |
limits: | |
memory: 4G | |
networks: | |
esnet: | |
driver: overlay | |
attachable: true | |
name: esnet | |
volumes: | |
esdata1: | |
esdata2: | |
esdata3: | |
esdata4: | |
esmaster1: | |
esmaster2: | |
esmaster3: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice to include doc on the node labels required