docker compose一键启动ES集群和kibana

发布于:2024-12-07 ⋅ 阅读:(28) ⋅ 点赞:(0)

集群启用了XPACK后,只有第一次可以启动成功。要是宕机了。就启动不了了。(除非删除data目录所有数据)生产环境 启用了后 建议配置 自定义证书。

services:
  es01:
    image: "docker.elastic.co/elasticsearch/elasticsearch:7.17.25"
    container_name: es01
    ports:
      - "9200:9200"
      - "9300:9300"
    privileged: true
    environment:
      node.name: es01
      discovery.seed_hosts: es01,es02,es03
      cluster.initial_master_nodes: es01
      cluster.name: myescluster
      node.master: true
      node.data: true
      http.cors.enabled: true
      bootstrap.memory_lock: true
      http.cors.allow-origin: "*"
      ES_JAVA_OPTS: -Xms512m -Xmx512m
      xpack.security.enabled: true
      ingest.geoip.downloader.enabled: false
      ELASTIC_PASSWORD: password
    volumes:
      - "/usr/local/es_cluster/node_1/data:/usr/share/elasticsearch/data"
      - "/usr/local/es_cluster/node_1/logs:/usr/share/elasticsearch/logs"
      - "/usr/local/es_cluster/node_1/plugins:/usr/share/elasticsearch/plugins"
    networks:
      - es-network
    ulimits:
      memlock:
        soft: -1
        hard: -1
  es02:
    image: "docker.elastic.co/elasticsearch/elasticsearch:7.17.25"
    container_name: es02
    ports:
      - "9201:9200"
      - "9301:9300"
    privileged: true
    environment:
      node.name: es02
      discovery.seed_hosts: es01,es02,es03
      cluster.name: myescluster
      node.master: true
      node.data: true
      http.cors.enabled: true
      bootstrap.memory_lock: true
      http.cors.allow-origin: "*"
      ES_JAVA_OPTS: -Xms512m -Xmx512m
      xpack.security.enabled: true
      ingest.geoip.downloader.enabled: false
      ELASTIC_PASSWORD: password
    volumes:
      - "/usr/local/es_cluster/node_2/data:/usr/share/elasticsearch/data"
      - "/usr/local/es_cluster/node_2/logs:/usr/share/elasticsearch/logs"
      - "/usr/local/es_cluster/node_2/plugins:/usr/share/elasticsearch/plugins"
    networks:
      - es-network
    ulimits:
      memlock:
        soft: -1
        hard: -1
  es03:
    image: "docker.elastic.co/elasticsearch/elasticsearch:7.17.25"
    container_name: es03
    ports:
      - "9202:9200"
      - "9302:9300"
    privileged: true
    environment:
      node.name: es03
      discovery.seed_hosts: es01,es02,es03
      cluster.name: myescluster
      node.master: true
      node.data: true
      http.cors.enabled: true
      bootstrap.memory_lock: true
      http.cors.allow-origin: "*"
      ES_JAVA_OPTS: -Xms512m -Xmx512m
      xpack.security.enabled: true
      ingest.geoip.downloader.enabled: false
      ELASTIC_PASSWORD: password
    volumes:
      - "/usr/local/es_cluster/node_3/data:/usr/share/elasticsearch/data"
      - "/usr/local/es_cluster/node_3/logs:/usr/share/elasticsearch/logs"
      - "/usr/local/es_cluster/node_3/plugins:/usr/share/elasticsearch/plugins"
    networks:
      - es-network
    ulimits:
      memlock:
        soft: -1
        hard: -1
  kibana:
    image: docker.elastic.co/kibana/kibana:7.17.25
    container_name: kibana
    depends_on:
      - es01
      - es02
      - es03
    ports:
      - "5601:5601"
      - "9600:9600"
    environment:
      SERVERNAME: kibana
      ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]'
      ES_JAVA_OPTS: -Xmx512m -Xms512m
      ELASTICSEARCH_USERNAME: elastic
      ELASTICSEARCH_PASSWORD: password
      xpack.security.enabled: true
      I18N_LOCALE: zh-CN
      SERVER_PUBLICBASEURL: "http://ip:5601"
    networks:
      - es-network
networks:
  es-network:
    driver: bridge

网站公告

今日签到

点亮在社区的每一天
去签到