Springboot弹性搜索运行状况管理:ConnectException:连接被拒绝 [英] Springboot elastic search health management : ConnectException: Connection refused
问题描述
在我的spring yaml文件中:
In my spring yaml file:
spring:
application:
name: myApp
elasticsearch:
jest:
uris: ["http://myelasticserver:9200"]
multi-threaded: true
read-timeout: 10000
management:
health:
elasticsearch:
indices: ["one","two"]
response-timeout: 1000
enabled: true
实际上,Jest客户端可以被注入和使用而没有任何问题。但是以某种方式,运行状况检查始终会因以下错误而失败:
Thing is, the Jest client can be injected and used without any problem. But somehow, the health check always fails with this error:
Elasticsearch运行状况检查失败java.net.ConnectException:
连接被拒绝
Elasticsearch health check failed java.net.ConnectException: Connection refused
URL似乎是 http: //没有使用myelasticserver:9200 ,而运行状况检查则改为使用localhost:9200。
It seems like the URL "http://myelasticserver:9200" wasn't used, and health check use localhost:9200 instead.
有人知道我在做什么错吗?
Does anyone know what did I do wrong?
谢谢。
推荐答案
Spring boot elasticsearch需要知道连接到哪个端口(和主机)以进行健康检查。添加:
Spring boot elasticsearch needs to know to which port (and host) to connect for the health check. Add:
spring:
elasticsearch:
rest:
uris: "myelasticserver:9200"
#username: ""
#password: ""
除了您已经拥有的配置。这是分开的,因为像我一样,许多人使用elasticsearch的(非http)端口9300进行实际搜索,而不是使用配置的一部分。我都没有management.health.elasticsearch。我对Elasticsearch的总体配置是:
This is in addition to the config you already have. This is separate because many people, like me, use the (non-http) port 9300 of elasticsearch for the actual searches instead of your part of the config. I neither have management.health.elasticsearch. My total config for elasticsearch is:
spring:
elasticsearch:
rest:
uris: "myelasticserver:9200"
data:
elasticsearch:
cluster-nodes: "myelasticserver:9300"
cluster-name: "my-cluster-name"
这篇关于Springboot弹性搜索运行状况管理:ConnectException:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!