docker-compose 配置 elasticsearch7.6集群

记录一下docker-compose 配置 elasticsearch集群,

docker-compose.yml: 

version: '3'
services:
  es01:
    image: elasticsearch:7.6.0
    container_name: es01
    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
    volumes:
      - ./es01/data:/usr/share/elasticsearch/data
      - ./es01/logs:/usr/share/elasticsearch/logs
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9200:9200
    networks:
      - elastic

  es02:
    image: elasticsearch:7.6.0
    container_name: es02
    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
    volumes:
      - ./es02/data:/usr/share/elasticsearch/data
      - ./es02/logs:/usr/share/elasticsearch/logs
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9201:9200
    networks:
      - elastic

  es03:
    image: elasticsearch:7.6.0
    container_name: es03
    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
    volumes:
      - ./es03/data:/usr/share/elasticsearch/data
      - ./es03/logs:/usr/share/elasticsearch/logs
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9202:9200
    networks:
      - elastic

  kibana01:
    image: kibana:7.6.0
    container_name: kibana01
    links:
      - es01
      - es02
      - es03
    ports:
      - 5601:5601
    volumes:
      - ./kibana_config/:/usr/local/kibana/config/
    environment:
      ELASTICSEARCH_HOSTS: http://es01:9200
    networks:
      - elastic
  head:
    image: docker.io/tobias74/elasticsearch-head
    container_name: efk-head
    links:
      - es01
      - es02
      - es03
    ports:
      - 9100:9100
    environment:
      ELASTICSEARCH_HOSTS: http://es01:9200
    networks:
      - elastic

networks:
  elastic:
    driver: bridge

elasticsearch.yml:

network.host: 0.0.0.0

http.cors.enabled: true
http.cors.allow-origin: "*"

最后,docker-compose up启动即可。

docker-compose 配置 elasticsearch7.6集群_第1张图片

docker-compose 配置 elasticsearch7.6集群_第2张图片

你可能感兴趣的:(docker-compose 配置 elasticsearch7.6集群)