无法连接到我的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
Docker文件
FROM elasticsearch, kibana
EXPOSE 9200
EXPOSE 9300
(在没有Docker的情况下运行本地安装的Elasticsearch即可!)
我究竟做错了什么?知道如何解决吗?
当降级到Elasticsearch:2.4.4时,它可以工作,我怀疑这与SpringData与最新的Elasticsearch不兼容有关。
...
services:
elasticsearch:
image: elasticsearch:2.4.4
ports:
- '9200:9200'
- '9300:9300'
kibana:
image: kibana:4.6.1
...
图表:
https://github.com/spring-projects/spring-data-elasticsearch
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句