docker-compose部署es集群
2021/4/25 10:57:38
本文主要是介绍docker-compose部署es集群,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
通过docker-compose部署es集群。es最新版本:7.5.1
mkdir -p /home/elfk/elasticsearch/configmkdir /home/elfk/elasticsearch/{data1,data2,data3}cd /home/elfkecho 'ELK_VERSION=7.5.1' > .env
tree ..├── docker-compose.yml └── elasticsearch ├── config │ └── elasticsearch.yml ├── data1 ├── data2 ├── data3 └── Dockerfile 5 directories, 3 files
elasticsearch
Dockerfile
vim /home/elfk/elasticsearch/Dockerfile
ARG ELK_VERSION=7.5.1 # https://github.com/elastic/elasticsearch-docker # FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION} FROM elasticsearch:${ELK_VERSION} # Add your elasticsearch plugins setup here # Example: RUN elasticsearch-plugin install analysis-icu
elasticsearch.yml
vim /home/elfk/elasticsearch/config/elasticsearch.yml
---## Default Elasticsearch configuration from Elasticsearch base image.## https://github.com/elastic/elasticsearch/blob/master/distribution/docker/src/docker/config/elasticsearch.yml#cluster.name: "es-docker-cluster"network.host: 0.0.0.0## X-Pack settings## see https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-xpack.html#xpack.license.self_generated.type: trial #trial为试用版,一个月期限,可更改为basic版本xpack.security.enabled: truexpack.monitoring.collection.enabled: truehttp.cors.enabled: truehttp.cors.allow-origin: "*"http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
docker-compose.yml
vim /home/elfk/docker-compose.yml
version: '3.7'services: es01: build: context: elasticsearch/ args: ELK_VERSION: $ELK_VERSION container_name: es01 volumes: - type: bind source: ./elasticsearch/config/elasticsearch.yml target: /usr/share/elasticsearch/config/elasticsearch.yml read_only: true - type: volume source: data01 target: /usr/share/elasticsearch/data ports: - 9200:9200 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.seed_hosts=es02,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 networks: - elastic es02: build: context: elasticsearch/ args: ELK_VERSION: $ELK_VERSION container_name: es02 volumes: - type: bind source: ./elasticsearch/config/elasticsearch.yml target: /usr/share/elasticsearch/config/elasticsearch.yml read_only: true - type: volume source: data02 target: /usr/share/elasticsearch/data environment: - node.name=es02 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 networks: - elastic es03: build: context: elasticsearch/ args: ELK_VERSION: $ELK_VERSION container_name: es03 volumes: - type: bind source: ./elasticsearch/config/elasticsearch.yml target: /usr/share/elasticsearch/config/elasticsearch.yml read_only: true - type: volume source: data03 target: /usr/share/elasticsearch/data environment: - node.name=es03 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es02 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 networks: - elasticvolumes: data01: driver: local driver_opts: type: none o: bind device: /home/elfk/elasticsearch/data1 data02: driver: local driver_opts: type: none o: bind device: /home/elfk/elasticsearch/data2 data03: driver: local driver_opts: type: none o: bind device: /home/elfk/elasticsearch/data3networks: elastic: driver: bridge
if [ $(grep 'vm.max_map_count' /etc/sysctl.conf |wc -l) -eq 0 ] ; \then echo 'vm.max_map_count=655360' >> /etc/sysctl.conf; \fisysctl -p docker-compose up --build -d
docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5af70e32dbb8 elfk_es01 "/usr/local/bin/dock…" 14 seconds ago Up 6 seconds 0.0.0.0:9200->9200/tcp, 9300/tcp es01 793bab4160b7 elfk_es03 "/usr/local/bin/dock…" 14 seconds ago Up 6 seconds 9200/tcp, 9300/tcp es03 93ffa61c639f elfk_es02 "/usr/local/bin/dock…" 14 seconds ago Up 6 seconds 9200/tcp, 9300/tcp es02netstat -lntp Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1303/master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 936/sshd tcp6 0 0 ::1:25 :::* LISTEN 1303/master tcp6 0 0 :::9200 :::* LISTEN 8724/docker-proxy tcp6 0 0 :::22 :::* LISTEN 936/sshd
这篇关于docker-compose部署es集群的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-19Docker-Compose容器集群化项目实战:新手入门指南
- 2024-11-19Docker镜像仓库项目实战:新手入门教程
- 2024-11-19Docker容器化部署项目实战:新手入门教程
- 2024-11-19Docker-Compose容器集群化资料入门教程
- 2024-11-19Docker镜像仓库资料详解:新手入门教程
- 2024-11-19Docker容器化部署资料:新手入门指南
- 2024-11-19Docker-Compose容器集群化教程:从入门到实践
- 2024-11-19Docker镜像仓库教程:新手入门指南
- 2024-11-19Docker容器化部署教程:初学者指南
- 2024-11-18Docker-Compose容器集群化入门教程