0

我在这里使用回购:https ://github.com/deviantony/docker-elk

CentOS 8

ELK 版本 7.4.0

码头工人撰写版本 1.24.1

Docker 版本 18.06.3-ce

当我启动容器时,Elasticsearch 加载正常。加载后,Kibana 和 Logstash 容器将启动。但是一旦加载,他们就无法看到 Elasticsearch 容器,从而产生以下消息:

日志存储:

[2019-10-22T18:32:57,321][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://elastic:xxxxxx@elasticsearch:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://elastic:xxxxxx@elasticsearch:9200/][Manticore::SocketException] No route to host (Host unreachable)"}

基巴纳:

{"type":"log","@timestamp":"2019-10-22T18:41:22Z","tags":["warning","elasticsearch","data"],"pid":6,"message":"Unable to revive connection: http://elasticsearch:9200/"}
{"type":"log","@timestamp":"2019-10-22T18:41:22Z","tags":["warning","elasticsearch","data"],"pid":6,"message":"No living connections"}
{"type":"log","@timestamp":"2019-10-22T18:41:22Z","tags":["license","warning","xpack"],"pid":6,"message":"License information from the X-Pack plugin could not be obtained from Elasticsearch for the [data] cluster. Error: No Living connections"}
{"type":"log","@timestamp":"2019-10-22T18:41:22Z","tags":["warning","elasticsearch","admin"],"pid":6,"message":"Unable to revive connection: http://elasticsearch:9200/"}
{"type":"log","@timestamp":"2019-10-22T18:41:22Z","tags":["warning","elasticsearch","admin"],"pid":6,"message":"No living connections"}

当我查看 elasticsearch 主机名是什么时,我得到了 Docker 自动生成的主机名。

# docker-compose exec elasticsearch hostname
7d50d6a75028

我的印象是,如果容器在同一个网络下,那么 docker 应该将 elasticsearch:9200 映射到容器的正确 IP 地址?

我尝试在 docker-compose 文件中设置主机名,如下所示:

...

services:
  elasticsearch:
    hostname: elasticsearch

...

并且变化反映在容器中:

# docker-compose exec elasticsearch hostname
elasticsearch

但是 Kibana 和 Logstash 仍然没有看到。

我无法从 Kibana 容器中看到该主机:

# docker-compose exec kibana curl http://elasticsearch:9200
curl: (7) Failed connect to elasticsearch:9200; No route to host

检查 ES 容器中的日志,它似乎工作正常:

# docker logs 9ef8

{"type": "server", "timestamp": "2019-10-22T18:50:55,870Z", "level": "INFO", "component": "o.e.c.r.a.AllocationService", "cluster.name": "docker-cluster", "node.name": "elasticsearch", "message": "Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[.monitoring-es-7-2019.10.22][0]]]).", "cluster.uuid": "O7t3UC1tSFibbjkwjqbX6A", "node.id": "qbzcFdQpR2KHBad-s8U1Vw"  }

我一定错过了一些东西,但我不知道它是。我搜索了这个错误,似乎我设置它的方式应该可以工作。

任何人都可以帮忙吗?

我的 docker-compose 文件如下所示:

version: '3.7'

services:
  elasticsearch:
    build:
      context: elasticsearch/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: bind
        source: ./elasticsearch/config/elasticsearch.yml
        target: /usr/share/elasticsearch/config/elasticsearch.yml
        read_only: true
      - type: volume
        source: elasticsearch
        target: /usr/share/elasticsearch/data
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      - elk

  logstash:
    build:
      context: logstash/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: bind
        source: ./logstash/config/logstash.yml
        target: /usr/share/logstash/config/logstash.yml
        read_only: true
      - type: bind
        source: ./logstash/pipeline
        target: /usr/share/logstash/pipeline
        read_only: true
    ports:
      - "5000:5000"
      - "9600:9600"
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      - elk
    depends_on:
      - elasticsearch

  kibana:
    build:
      context: kibana/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: bind
        source: ./kibana/config/kibana.yml
        target: /usr/share/kibana/config/kibana.yml
        read_only: true
    ports:
      - "5601:5601"
    networks:
      - elk
    depends_on:
      - elasticsearch

networks:
  elk:
    driver: bridge

volumes:
4

2 回答 2

0

即使我在 CENTOS 8 的 docker 中运行 elastic,kibana 也有同样的问题。

看起来有些问题,因为 kibana 无法与 docker network 中的弹性通信。

kibana 内的 CURL 到弹性:curl -X GET http://elasticsearch:9200抛出错误Failed connect to elasticsearch:9200; No route to host

相同的 docker-compose 文件在 windows docker , docker 在 ubuntu 等中工作,..

编辑:

经过一番搜索,我能够想出解决方案。原因是centos firewalld阻止了 docker 容器网络中的 DNS,需要完全绕过或禁用它。但是,不是完全禁用,而是能够通过使用此处firewalld显示的步骤绕过防火墙中的 docker DNS找到解决方法发布执行步骤后,kibana 能够与 docker 内部的 Elastic 连接 .. 谢谢 :)

于 2020-01-22T19:24:59.603 回答
0

我能够让它在 CentOS 7.7 上运行而没有问题。似乎与 CentOS 8 相关。

于 2019-10-23T17:35:11.007 回答