docker-compose容器编排搭建ES集群ELK环境

发布日期: 2020-08-01 13:51:49 作者: Stephen 评论: 2

使用docker-compose容器编排技术,搭建ES集群,包含ElasticSearch、Logstash、Kibana,使用的是目前官方提供的最新版本7.8.0。前期呢,自己也踩了很多的坑,把它分享一下

新建docker-compose.yml

version: '2.2'
services:
  kibana:
    image: kibana:7.8.0
    container_name: kibana7
    environment:
      - I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    ports:
      - 5601:5601
    networks:
      - elastic

  elasticsearch:
    image: elasticsearch:7.8.0
    container_name: es7
    environment:
      - node.name=es7
      - cluster.name=es-cluster
      - discovery.seed_hosts=es7,es7_02
      - cluster.initial_master_nodes=es7,es7_02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ~/Docker/env/elastic/es/data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - elastic

  elasticsearch2:
    image: elasticsearch:7.8.0
    container_name: es7_02
    environment:
      - node.name=es7_02
      - cluster.name=es-cluster
      - discovery.seed_hosts=es7,es7_02
      - cluster.initial_master_nodes=es7,es7_02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ~/Docker/env/elastic/es2/data:/usr/share/elasticsearch/data
    networks:
      - elastic

  logstash:
    image: logstash:7.8.0
    container_name: logstash7
    volumes:
      - ~/Docker/env/elastic/logstash/logstash.conf:/usr/share/logstash/logstash.conf
    networks:
      - elastic

networks:
  elastic:
    driver: bridge

容器编排:

docker-compose up -d

如果是linux root用户,需要给宿主机映射目录赋权

chmod -R 775 ~/Docker/env/elastic/es/data
chmod -R 775 ~/Docker/env/elastic/es2/data

运行

ES集群验证

查看ES节点

GET _cat/nodes

验证ES集群健康度

GET _cluster/health

如下图所示,status 值为 green 表示集群环境正常

杜老师说 2周前
已经添加贵站链接,祝贵博客越办越好!
Teacher Du 2周前
您好,我是菜鸟博客博主,因为一些原因,菜鸟博客不再运营,友情链接转至杜老师说,网址是dusays.com,如果您有意愿,欢迎交换新站链接!