2.7 在Docker容器中运行Elasticsearch、Kibana和Cerebro

安装 Docker 和 Docker-Compose

下载安装 Dokcer 与 Docker Compose

  • www.docker.com
  • https://docs.docker.com/compose/
  • https://docs.docker.com/machine/install-machine/

Docker-Compose 相关命令

运行docker-compose up
docker compose down
docker compose down -v
docker stop / rm containerID

相关阅读

  • 安装docker https://www.docker.com/products/docker-desktop
  • 安装 docker-compose https://docs.docker.com/compose/install/
  • 如何创建自己的Docker Image - https://www.elastic.co/cn/blog/how-to-make-a-dockerfile-for-elasticsearch
  • 如何在为docker image安装 Elasticsearch 插件 - https://www.elastic.co/cn/blog/elasticsearch-docker-plugin-management
  • 如何设置 Docker 网络 - https://www.elastic.co/cn/blog/docker-networking
  • Cerebro 源码 https://github.com/lmenezes/cerebro
  • 一个开源的 ELK(Elasticsearch + Logstash + Kibana) docker-compose 配置 https://github.com/deviantony/docker-elk
  • Install Elasticsearch with Docker https://www.elastic.co/guide/en/elasticsearch/reference/7.2/docker.html

使用 Docker-Compose启动

  • 新建文件夹 docker-es-7.11.2
  • 新建文件 docker-compose.yml ,内容如下
version: '2.2'
services:
  cerebro:
    image: lmenezes/cerebro:0.8.3
    container_name: cerebro
    ports:
      - "9000:9000"
    command:
      - -Dhosts.0.host=http://elasticsearch:9200
    networks:
      - es7net
  kibana:
    image: docker.elastic.co/kibana/kibana:7.11.2
    container_name: kibana7
    environment:
      - I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    ports:
      - "5601:5601"
    networks:
      - es7net
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.2
    container_name: es7_01
    environment:
      - cluster.name=geektime
      - node.name=es7_01
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
      - discovery.seed_hosts=es7_01,es7_02
      - cluster.initial_master_nodes=es7_01,es7_02
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es7data1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - es7net
  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.2
    container_name: es7_02
    environment:
      - cluster.name=geektime
      - node.name=es7_02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
      - discovery.seed_hosts=es7_01,es7_02
      - cluster.initial_master_nodes=es7_01,es7_02
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es7data2:/usr/share/elasticsearch/data
    networks:
      - es7net


volumes:
  es7data1:
    driver: local
  es7data2:
    driver: local

networks:
  es7net:
    driver: bridge

启动命令

docker-compose up

拉取镜像

image-20210317125732616

启动成功

image-20210317125918749

  • 查看 Elasticsearch 状态

    • 打开浏览器输入地址:http://localhost:9200/
  • 查看 Kibana 状态

    • 打开浏览器输入地址:http://localhost:5601/
  • 查看 Cerebro 状态

    • 打开浏览器输入地址:http://localhost:9000/

猜你喜欢

转载自blog.csdn.net/baoshuowl/article/details/114926047
2.7