在 Docker 中运行 Elasticsearch、Kibana 和 Cerebro(阿里云Ubuntu)

接上篇:Elasticsearch 7.x 的安装与简单配置(阿里云Ubuntu)

Cerebro 是一个使用 Scala,Play Framework,AngularJS 和 Bootstrap 构建的开源(MIT许可)elasticsearch web管理工具。 https://github.com/lmenezes/c...

系统环境

  • 操作系统:Ubuntu 18.04 LTS(阿里云)
  • 系统IP
# 内网,私有地址
172.内.内.内
# 外网,公有地址
112.外.外.外
  • Elasticsearch 版本:7.2
  • Kibana 版本:7.2
  • Cerebro 版本: 0.8.3
  • Docker 版本:18.09

安装 dcoker 及组件

  • 安装 docker
$ sudo apt install docker
# 将当前用户加入 docker 组,避免 root 权限运行 docker 命令
$ sudo usermod -aG docker ${USER}
$ docker --version
Docker version 18.09.7, build 2d0083d
  • 安装 docker.io
$ sudo apt install docker.io
  • 安装 docker-compose
$ sudo apt install docker-compose
$ docker-compose --version
docker-compose version 1.17.1, build unknown

配置 docker 镜像加速器

  • 阿里云控制台 -> 产品与服务 -> 弹性计算 -> 容器镜像服务

创建并启动 docker 容器

  • 将 docker-compose.yaml 保持到 Ubuntu 本地目录,内容如下,对原课程 github 上的文件有微调
  • 课程 docker-compose.yaml
# docker-compose.yaml
version: '2.2'
services:
  cerebro:
    image: lmenezes/cerebro:0.8.4
    container_name: cerebro
    ports:
      - "9000:9000"
    command:
      - -Dhosts.0.host=http://elasticsearch:9200
    networks:
      - es72net
  kibana:
    image: kibana:7.2.0
    container_name: kibana72
    environment:
      #- I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    ports:
      - "5601:5601"
    networks:
      - es72net
  elasticsearch:
    image: elasticsearch:7.2.0
    container_name: es72_01
    environment:
      - cluster.name=geektime
      - node.name=es72_01
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.seed_hosts=es72_01,es72_02
      #- network.publish_host=elasticsearch
      - cluster.initial_master_nodes=es72_01,es72_02
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es72data1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - es72net
  elasticsearch2:
    image: elasticsearch:7.2.0
    container_name: es72_02
    environment:
      - cluster.name=geektime
      - node.name=es72_02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.seed_hosts=es72_01,es72_02
      #- network.publish_host=elasticsearch
      - cluster.initial_master_nodes=es72_01,es72_02
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es72data2:/usr/share/elasticsearch/data
    networks:
      - es72net

volumes:
  es72data1:
    driver: local
  es72data2:
    driver: local

networks:
  es72net:
    driver: bridge
  • 在 docker-compose.yaml 所在目录运行以下命令,创建并启动容器
$ docker-compose up

安全组端口

  • 本文涉及应该放行的安全组端口有3个
elasticsearch: 9200
kibana: 5601
cerebro: 9000

结果查看

  • 查看磁盘挂载信息
$ docker volume ls
DRIVER              VOLUME NAME
local               docker_es72data1
local               docker_es72data2
$ docker volume inspect docker_es72data1
[
    {
        "CreatedAt": "2019-08-10T10:06:43+08:00",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "docker",
            "com.docker.compose.volume": "es72data1"
        },
        "Mountpoint": "/var/lib/docker/volumes/docker_es72data1/_data",
        "Name": "docker_es72data1",
        "Options": null,
        "Scope": "local"
    }
]
  • elasticsearch
# url
http://112.外.外.外:9200/_cat/health?v
# 页面内容
epoch      timestamp cluster  status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1565407420 03:23:40  geektime green           2         2      2   1    0    0        0             0                  -                100.0%
  • kibana 可以把测试数据加上
# url
http://112.外.外.外:5601

  • cerebro
# url
http://112.外.外.外:9000


本文是阮一鸣《 Elasticsearch核心技术与实战》的学习笔记。

你可能感兴趣的:(容器,docker-compose,docker,ubuntu,elasticsearch)