docker-compose構築elasticsearch 7.2.0+kibana環境

3037 ワード

一、docker-compose.yml

version: '3'
services:
  es01:
    image: "beng/es:7.2.0"
    build: .
    container_name: es01
    restart: always
    volumes:
      - ./es01/data:/usr/share/elasticsearch/data:rw
      - ./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:
      - esnet

  es02:
    image: "beng/es:7.2.0"
    build: .
    container_name: es02
    restart: always
    volumes:
       - ./es02/data:/usr/share/elasticsearch/data:rw
       - ./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:
      - esnet

  es03:
    image: "beng/es:7.2.0"
    build: .
    container_name: es03
    restart: always
    volumes:
      - ./es03/data:/usr/share/elasticsearch/data:rw
      - ./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:
      - esnet

  kibana:
    image: docker.elastic.co/kibana/kibana:7.2.0
    container_name: kibana
    ports:
      - 5601:5601
    volumes:
      - ./kibana/kibana.yml:/usr/share/kibana/config/kibana.yml:rw
    networks:
      - esnet
      
networks:
  esnet:

二、elasticsearchインストールelasticsearch-analysis-ikの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/*

三、kibanaプロファイル


docker-composeファイルでenvironmentが有効になっていないため(原因が見つからない)、プロファイルはディスクマッピングで設定されます.
#
# ** THIS IS AN AUTO-GENERATED FILE **
#

# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://es01:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: zh-CN