新建 Dockerfile 文件
FROM docker.elastic.co/elasticsearch/elasticsearch:7.2.0
ENV VERSION=7.2.0
# https://github.com/medcl/elasticsearch-analysis-ik/releases
# 中文分词插件下载
ADD https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v${VERSION}/elasticsearch-analysis-ik-$VERSION.zip /tmp/
# 中文分词插件安装
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install -b file:///tmp/elasticsearch-analysis-ik-$VERSION.zip
RUN rm -rf /tmp/*
新建 docker-compose.yml 文件
version: '3'
services:
es01:
image: "elasticsearch:7.2.0"
build: .
container_name: es01
restart: always
volumes:
- ./.docker/es01/data:/usr/share/elasticsearch/data:rw
- ./.docker/es01/logs:/user/share/elasticsearch/logs:rw
environment:
- node.name=es01
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es02:9300,es03:9300
- cluster.initial_master_nodes=es01,es02,es03
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9200:9200"
- "9300:9300"
networks:
- app
es02:
image: "elasticsearch:7.2.0"
build: .
container_name: es02
restart: always
volumes:
- ./.docker/es02/data:/usr/share/elasticsearch/data:rw
- ./.docker/es02/logs:/user/share/elasticsearch/logs:rw
environment:
- node.name=es02
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es01:9300,es03:9300
- cluster.initial_master_nodes=es01,es02,es03
ulimits:
memlock:
soft: -1
hard: -1
networks:
- app
es03:
image: "elasticsearch:7.2.0"
build: .
container_name: es03
restart: always
volumes:
- ./.docker/es03/data:/usr/share/elasticsearch/data:rw
- ./.docker/es03/logs:/user/share/elasticsearch/logs:rw
environment:
- node.name=es03
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es01:9300,es02:9300
- cluster.initial_master_nodes=es01,es02,es03
ulimits:
memlock:
soft: -1
hard: -1
networks:
- app
kibana:
image: docker.elastic.co/kibana/kibana:7.2.0
container_name: kibana
ports:
- 5601:5601
volumes:
- ./.docker/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml:rw
networks:
- app
networks:
app:
启动集群
$ docker-compose up -d