Docker容器中运行Elasticsearch+Kibana,打不开Kibana界面

这是一篇像日记一样的记录。
本来目的是记录排查和解决问题的过程,但是中途莫名其妙问题自己消失了,于是变成了无解的操作记录。
docker-compose.yml内容如下:

version: '2.2'
services:
  kibana:
    image: docker.elastic.co/kibana/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: docker.elastic.co/elasticsearch/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
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es72data1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - es72net
volumes:
  es72data1:
    driver: local

networks:
  es72net:
    driver: bridge

运行docker-compose up命令,浏览器进入localhost:9200查看Elasticsearch正常。
进入localhost:5601界面查看Kibana却报错‘无法访问此网站’。
在docker-compose up命令窗口,es72_01有报错‘failed to resolve hsot [es72_02]’,表明另一个Elasticsearch服务es72_01没有在脚本里删除干净。
kibana72有报错’Unable to recieve connection:http://elsaticsearch:9200/’
???成功打开了???
一边重新尝试一边记录到这里的时候,突然发现Kibana页码localhost:5601/可以打开了,此时docker-compose只运行了一个Elasticsearch服务es72_01和一个kibana72服务。
把cerebro和另一个Elasticsearch服务加入脚本:

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:
      - es72net
  kibana:
    image: docker.elastic.co/kibana/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: docker.elastic.co/elasticsearch/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: docker.elastic.co/elasticsearch/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

运行后,kibana界面仍然可以打开。
打开cerebro界面localhost:9000,点击连接集群。可以连接成功。
Docker容器中运行Elasticsearch+Kibana,打不开Kibana界面_第1张图片
但是发现只有一个节点es72_01, 另一个节点es72_02不知所踪。

重试,发现窗口有日志打印:
master not discovered yet,
this node has not previously joined a bootstrapped (v7+) cluster,
and this node must discover master-eligible nodes [es72_01, es72_02] to bootstrap a cluster: have discovered [];
discovery will continue using [172.18.0.2:9300] from hosts providers and [{es72_02}{8_sinuJPSq6uOnlpYQB9Dg}{RJryT33ERz-oX5dBIQGIyA}{elasticsearc
大意是说没有找到主节点,应该在节点启动之前把它加入到自荐的集群中。

你可能感兴趣的:(学习)