【发布时间】:2018-09-01 12:28:09
【问题描述】:
无法连接到我的 Elasticsearch,开始于:
docker-compose up
运行命令:
curl -XGET http://localhost:9200/_nodes/http?pretty
输出:
{
"cluster_name" : "elasticsearch",
"nodes" : {
"qD18rHzhQaexExUw5sBgXg" : {
"name" : "Scanner",
"transport_address" : "172.19.0.3:9300",
"host" : "172.19.0.3",
"ip" : "172.19.0.3",
"version" : "6.2.3",
"build" : "fcbb46d",
"http_address" : "172.19.0.3:9200",
"http" : {
"bound_address" : [ "0.0.0.0:9200" ],
"publish_address" : "172.19.0.3:9200",
"max_content_length_in_bytes" : 104857600
}
}
}
}
与传输客户端连接:
public Client client() throws Exception {
Settings settings = Settings.builder()
.put("spring.data.elasticsearch.cluster-nodes", "localhost:9300")
.build();
TransportClient client = TransportClient.builder()
.settings(settings)
.build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
return client;
}
得到错误:
Caused by: NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{localhost}{127.0.0.1:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:326)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:223)
docker-compose.yml
services:
elasticsearch:
image: elasticsearch
ports:
- '9200:9200'
- '9300:9300'
kibana:
image: kibana
ports:
- '5601:5601'
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
Dockerfile
FROM elasticsearch, kibana
EXPOSE 9200
EXPOSE 9300
(运行本地安装的 Elasticsearch 没有 Docker 它可以工作!)
我做错了什么?知道如何解决吗?
【问题讨论】:
-
确保您的弹性客户端版本与您的弹性版本匹配!!那是我的问题。仍然得到 NoNodeAvailableException。
标签: java docker elasticsearch docker-compose elasticsearch-5