Docker Compose单机安装elasticsearch7.16.3

https://www.elastic.co/guide/en/elasticsearch/reference/7.16/docker.html

文件结构

└── elasticsearch
    ├── node-00
    │    ├── config
    │    │  └── elasticsearch.yml
    │    ├── data
    │    ├── docker-compose.yml
    │    ├── logs
    │    └── plugins
    │        └── ik
    ├── node-01
    │    ├── config
    │    │  └── elasticsearch.yml
    │    ├── data
    │    ├── docker-compose.yml
    │    ├── logs
    │    └── plugins
    │        └── ik
    └── node-02
        ├── config
        │    └── elasticsearch.yml
        ├── data
        ├── docker-compose.yml
        ├── logs
        └── plugins
            └── ik
chown 1000:1000 data
chown 1000:1000 logs

配置

  1. 创建公用docker network
docker network ls
docker network create --driver bridge elastic
  1. 创建各个node的docker-compose.yml
  • node-00
version: "3"
services:
  es-node-00:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.16.3
    container_name: es-node-00
    environment:
      - "TZ=Asia/Shanghai"
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    restart: always
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - elastic
    volumes:
      - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./data:/usr/share/elasticsearch/data
      - ./plugins:/usr/share/elasticsearch/plugins
      - ./logs:/usr/share/elasticsearch/logs
networks:
  elastic:
    external: true
  • node-01
version: "3"
services:
  es-node-01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.16.3
    container_name: es-node-01
    environment:
      - "TZ=Asia/Shanghai"
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    restart: always
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    ports:
      - 9201:9200
      - 9301:9300
    networks:
      - elastic
    volumes:
      - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./data:/usr/share/elasticsearch/data
      - ./plugins:/usr/share/elasticsearch/plugins
      - ./logs:/usr/share/elasticsearch/logs
networks:
  elastic:
    external: true
  • node-02
version: "3"
services:
  es-node-02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.16.3
    container_name: es-node-02
    environment:
      - "TZ=Asia/Shanghai"
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    restart: always
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    ports:
      - 9202:9200
      - 9302:9300
    networks:
      - elastic
    volumes:
      - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./data:/usr/share/elasticsearch/data
      - ./plugins:/usr/share/elasticsearch/plugins
      - ./logs:/usr/share/elasticsearch/logs
networks:
  elastic:
    external: true
  1. config/elasticsearch.yml
  • node-00
cluster.name: my-es-cluster
node.name: es-node-00
network.host: es-node-00
http.port: 9200
transport.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.seed_hosts: ["es-node-01", "es-node-02"]

bootstrap.memory_lock: true
cluster.initial_master_nodes: ["es-node-00", "es-node-01", "es-node-02"]

#disable the usage of geoip functionality
ingest.geoip.downloader.enabled: false
  • node-01
cluster.name: my-es-cluster
node.name: es-node-01
network.host: es-node-01
http.port: 9200
transport.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.seed_hosts: ["es-node-00", "es-node-02"]

bootstrap.memory_lock: true
cluster.initial_master_nodes: ["es-node-00", "es-node-01", "es-node-02"]

#disable the usage of geoip functionality
ingest.geoip.downloader.enabled: false
  • node-02
cluster.name: my-es-cluster
node.name: es-node-02
network.host: es-node-02
http.port: 9200
transport.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.seed_hosts: ["es-node-00", "es-node-01"]

bootstrap.memory_lock: true
cluster.initial_master_nodes: ["es-node-00", "es-node-01", "es-node-02"]

#disable the usage of geoip functionality
ingest.geoip.downloader.enabled: false

kibana

https://www.elastic.co/guide/en/kibana/7.16/docker.html