当前位置: 首页 > 知识库问答 >
问题:

无法使用docker compose连接到kibana/elasticsearch

狄富
2023-03-14

我试图运行KibanaElasticsearch通过docker-compose包含文件(. yml)在虚拟机中,但我无法连接到Kibana,并且在尝试连接失败时收到的消息如下所示:

[34mspark-master     |[0m 18/09/25 17:58:29 INFO master.Master: Registering worker 172.18.0.8:8881 with 2 cores, 1024.0 MB RAM
[36;1mspark-worker     |[0m 18/09/25 17:58:29 INFO worker.Worker: Successfully registered with master spark://spark-master:7077
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:31Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:31Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:33Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:33Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:36Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:36Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:38Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:38Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
[35mkibana           |[0m {"type":"log","@timestamp":"2018-09-25T17:58:41Z","tags":["status","plugin:elasticsearch@6.2.2","info"],"pid":1,"state":"green","message":"Status changed from red to green - Ready","prevState":"red","prevMsg":"Unable to connect to Elasticsearch at http://elasticsearch:9200."}
[33melasticsearch    |[0m 2018-09-25 17:58:47,078 INFO exited: create-index (exit status 0; expected)

如果您注意到,docker能够连接到docker compose文件中提到的其他服务,其中一个是前两行显示的spark master。在docker compose文件中调用kibana的命令如下:

  elasticsearch:
    build: docker-elasticsearch/
    container_name: elasticsearch
    hostname: elasticsearch
    environment:
      - Des.network.host=0.0.0.0
      - cluster.name = "elasticsearch"
    expose:
      - 9200
    ports:
      - "9200:9200"


  kibana:
    build: kibana/
    container_name: kibana
    hostname: kibana
    environment:
      - SERVER_NAME="kibana"
      - SERVER_HOST="0"
      - ELASTICSEARCH_URL=http://elasticsearch:9200
    ports:
      - "5601:5601"
    links:
      - elasticsearch
    depends_on:
      - elasticsearch

如果我做了docker compose ps,它会给我以下信息:

    Name                 Command             State              Ports           
--------------------------------------------------------------------------------
elasticsearch   /usr/local/bin/docker-entr   Up       0.0.0.0:9200->9200/tcp,   
                ...                                   9300/tcp                  
kibana          /bin/bash /usr/local/bin/k   Up       0.0.0.0:5601->5601/tcp 

在这里发布这个问题之前,我在google上广泛搜索了这个问题,并尝试了人们对这个问题的各种建议,包括修改elasticsearch_url,例如将超文本传输协议更改为https,将localhost更改为elasticsearch以及这两个建议的组合/排列,但我无法使用任何建议连接到Kibana。还建议在某个地方检查我的虚拟机分配的内存,对于我的VM,它等于Elasticsearch建议的值。

在使用@Ivthillo给出的命令时,似乎Kibana连接,如终端上的以下消息所示:

kibana_1         | {"type":"log","@timestamp":"2018-09-26T13:43:05Z","tags":["info","monitoring-ui","kibana-monitoring"],"pid":1,"message":"Starting all Kibana monitoring collectors"}
kibana_1         | {"type":"log","@timestamp":"2018-09-26T13:43:06Z","tags":["license","info","xpack"],"pid":1,"message":"Imported license information from Elasticsearch for the [monitoring] cluster: mode: basic | status: active"}
kibana_1         | {"type":"log","@timestamp":"2018-09-26T13:43:12Z","tags":["listening","info"],"pid":1,"message":"Server running at http://0:5601"}

但是,当我尝试在新终端中通过docker运行另一个服务(例如sudo docker exec-i)时(因为上面的消息服务器正在运行...仍然卡住,因为它没有向前移动),我收到一个错误,指示容器未运行如下:

Error response from daemon: Container 824846b64950d7e6f38792c5633f9eca3e84702cfe060de012c4fe39cf365ab9 is not running

共有2个答案

王楚青
2023-03-14

我有类似的设置。我通过管理容器网络解决了这个问题。尝试以下操作:

version: '3'
services:
 elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
    ports:
      - 9200:9200

  kibana:
    image: kibana:5.6.12
    container_name: kibana
    environment:
      ELASTICSEARCH_URL: http://elasticsearch1:9200
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

如果这有帮助,请告诉我。

夏奕
2023-03-14

您可以从这个非常基本的docker-compose开始,因为您正在构建自己的映像,这使得调试变得困难。

在下面的示例中,我们在同一个docker网络中启动一个ES和一个Kibana,这意味着它们可以使用它们的名称相互访问。与使用已弃用的--link相比,网络是使容器通信的更好方法。

version: '3.3'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:6.3.2
    environment:
      SERVER_NAME: kibana.example.org
      ELASTICSEARCH_URL: http://elasticsearch:9200
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
    networks:
      - my-network

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
    container_name: elasticsearch
    networks:
      - my-network

networks:
  my-network:

证明这种联系是有效的。我正在访问kibana容器,并ping和curl到我的elasticsearch容器:

$ docker ps
CONTAINER ID        IMAGE                                                 COMMAND                  CREATED             STATUS              PORTS                    NAMES
7e2632aff839        docker.elastic.co/kibana/kibana:6.3.2                 "/usr/local/bin/kiba…"   2 minutes ago       Up 2 minutes        0.0.0.0:5601->5601/tcp   es_kibana_1
03f2d03a87b4        docker.elastic.co/elasticsearch/elasticsearch:6.3.2   "/usr/local/bin/dock…"   2 minutes ago       Up 2 minutes        9200/tcp, 9300/tcp       elasticsearch
 lorenzvanthillo@MacBook-Pro  ~/ES  docker exec -it 7e2632aff839 bash
bash-4.2$ ping elasticsearch
PING elasticsearch (172.22.0.2) 56(84) bytes of data.
64 bytes from elasticsearch.es_my-network (172.22.0.2): icmp_seq=1 ttl=64 time=0.554 ms
64 bytes from elasticsearch.es_my-network (172.22.0.2): icmp_seq=2 ttl=64 time=0.075 ms
bash-4.2$ curl http://elasticsearch:9200
{
  "name" : "f9AfdJp",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "YQkmS6gtTmqcCs0HgWX5bg",
  "version" : {
    "number" : "6.3.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "053779d",
    "build_date" : "2018-07-20T05:20:23.451332Z",
    "build_snapshot" : false,
    "lucene_version" : "7.3.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
 类似资料:
  • 问题内容: 我已经在RHEL7上安装了ES 7.5和Kibana 7.5,但是在启动Kibana并检查UI后,我看到了错误,“ Kibana服务器尚未准备好。” 检查Kibana日志,我发现它没有正确连接到ES。任何帮助表示赞赏! 这是 journalctl –unit kibana 的输出: Elasticsearch.yml Kibana.yml 另外,当我运行 ss -tunlp | gre

  • 我已经在RHEL7上安装了ES 7.5和Kibana 7.5,但是在启动Kibana并检查UI之后,我看到了错误,“Kibana服务器还没有准备好。” 检查Kibana日志,我看到它没有正确连接到ES。感谢任何帮助! 以下是journalctl的输出——单位kibana: 弹性搜索。yml 基巴纳。yml 此外,当我在Kibana启动期间运行ss-tunlp|grep 5601时,我看到Kiban

  • 尝试使用Docker容器将Kibana连接到ES时出错: kibana-product-624|{"type":"log","@time戳":"2018-05-25T14:56:36Z","tags":["警告","elasticsearch","admin"],"pid": 1,"消息":"无法恢复连接:超文本传输协议://elasticsearch: 9200/"}kibana-product

  • 问题内容: 我已经在服务器上安装了Kibana 5.4和Elastic search 5.4,我可以通过使用本地计算机上的curl来访问Kibana和Elastic search 我得到以下回应 var hashRoute =’/ app / kibana’; var defaultRoute =’/ app / kibana’; var hash = window.location.hash;

  • 我已经在服务器上安装了Kibana 5.4和Elastic search 5.4,我可以使用 我得到以下回应 var hashRoute='/app/kibana'; var defaultRoute='/app/kibana'; var hash=window.location.hash; if(hash.length){window.location=hashRoute hash;}其他{wi

  • 问题内容: 我尝试创建Kibana和Elasticsearch,看来Kibana在识别Elasticsearch时遇到了麻烦。 这是我的步骤: 1)建立网络 2)运行Elasticsearch容器 3)运行Kibana容器 通过浏览器通过http:// localhost:9200 / 连接到Elasticsearch时,我得到JSON输出。 但是,当我打开HTTP://本地主机:5601 /我得