docker-compose 搭建elaticsearch集群+kibana+eshead+cerebro

安装docker官网地址:

https://docs.docker.com/engine/install/centos/

安装docker-compos官网地址:

https://docs.docker.com/compose/install/

The vm.max_map_count kernel setting must be set to at least 262144 for production use
vi  /etc/sysctl.conf 
vm.max_map_count=262144
sysctl -p生效配置

docker-compose.yml

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.3
    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=-Xms1g -Xmx1g"
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - xpack.security.enabled=false   
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./es01/data:/usr/share/elasticsearch/data
      - ./es01/logs:/usr/share/elasticsearch/logs
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.3
    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=-Xms1g -Xmx1g"
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - xpack.security.enabled=false 
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./es02/data:/usr/share/elasticsearch/data
      - ./es02/logs:/usr/share/elasticsearch/logs
    ports:
      - 9201:9200
      - 9301:9300
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.3
    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=-Xms1g -Xmx1g"
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - xpack.security.enabled=false 
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./es03/data:/usr/share/elasticsearch/data
      - ./es03/logs:/usr/share/elasticsearch/logs
    ports:
      - 9202:9200
      - 9302:9300
    networks:
      - elastic
  kibana:
    image: kibana:7.13.3
    container_name: kibana
    restart: always
    environment:
      - I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    ports:
      - 5601:5601
    links:
      - es01:elasticsearch
    depends_on:
      - es01
    networks:
      - elastic
  eshead:    
    image: mobz/elasticsearch-head:5
    container_name: eshead
    networks:
      - elastic
    ports:
      - 9100:9100
  cerebro:
    image: lmenezes/cerebro:0.8.3
    container_name: cerebro
    ports:
        - 9000:9000
    command:
        - -Dhosts.0.host=http://es01:9200
    networks:
        - elastic
volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge

构建后会自动在当前目录下创建文件夹

需要给文件夹权限才能启动es集群否则会报错

启动命令       docker-compose up 
停止命令       docker-compose stop
停止并删除容器  docker-compose down
posted @ 2021-07-16 17:32  王诚意  阅读(176)  评论(0编辑  收藏  举报