gpt4 book ai didi

docker - Kibana无法恢复与ElasticSearch的连接

转载 作者:行者123 更新时间:2023-12-02 21:03:37 24 4
gpt4 key购买 nike

我是ElasticSearch的新手,我在这里按照说明进行操作:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
每当我运行“docker-compose up”时,Kibana总是会说“无法恢复连接”,但是如果我运行curl http:// localhost:9200,我会得到响应:

{
"name" : "ec88fa675367",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "UkLkAHO8S4yzAKFaf0KsYA",
"version" : {
"number" : "7.5.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "e9ccaed468e2fac2275a3761849cbee64b39519f",
"build_date" : "2019-11-26T01:06:52.518245Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
以下是我的docker-compose.yml,请帮助,谢谢!
version: '3'

networks:
elastic:

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: elasticsearch
networks:
- elastic
environment:
- discovery.type=single-node
ports:
- 9200:9200

kibana:
image: docker.elastic.co/kibana/kibana:7.5.0
container_name: kibana
networks:
- elastic
environment:
SERVER_NAME: kibana
ELASTICSEARCH_HOSTS: http://localhost:9200
links:
- elasticsearch
depends_on:
- elasticsearch

最佳答案

它不起作用的原因是因为您将ELASICSEARCH_HOSTS设置为Kibana主机(因为localhost代表kibana容器)。您需要做的是使用elasticsearch主机名ELASTICSEARCH_HOSTS: http://elasticsearch:9200
您还需要映射您的Kibana端口,否则您将无法从本地计算机访问它(类似于您对elasticsearch所做的操作)。
下面的示例应该工作:

version: '3'

networks:
elastic:

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: elasticsearch
networks:
- elastic
environment:
- discovery.type=single-node
ports:
- 9200:9200

kibana:
image: docker.elastic.co/kibana/kibana:7.5.0
container_name: kibana
networks:
- elastic
environment:
SERVER_NAME: kibana
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
links:
- elasticsearch
depends_on:
- elasticsearch
ports:
- 5601:5601

关于docker - Kibana无法恢复与ElasticSearch的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59257213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com