ElasticSearch GetApi NoNodeAvailableException

时间:2017-07-18 15:57:25

标签: java elasticsearch

我尝试使用弹性搜索文档https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-get.html从我刚创建的索引中获取文档

我的整个代码是:

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
GetResponse response = client.prepareGet("twitter", "tweet", "1").get();

我得到以下异常(当我到达'get'行时):

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{dUtRDm92Tg6ob6GVMtbgWA}{127.0.0.1}{127.0.0.1:9300}]]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)
    at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
    at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363)
    at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
    at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:62)
    at 

我搜索了答案并得到了以下解决方案:

我使用相同版本的弹性搜索5.5.0 Elasticsearch NoNodeAvailableException

给出集群的名称(如果在elasticsearch.yml中更改了) Java ElasticSearch None of the configured nodes are available NoNodeAvailableException : None of the configured nodes are available

另一个解决方案是端口 - 使用9200-9300,9300-9400 并尝试使用client.transport.sniff选项 Java ElasticSearch None of the configured nodes are available

另一个解决方案是将network.bind_host:0添加到yml - How to bind Elasticsearch 2.0 on both Loopback and Non-Loopback interfaces?

我的防火墙已关闭

这些解决方案中没有一个适合我。 这应该是超级简单的,弹性搜索安装是全新的。 我错过了什么?

1 个答案:

答案 0 :(得分:0)

分享您的完整Java代码。 Elasticsearch使用了两个端口。端口9200通过http(例如您的浏览器)提供访问。端口9300用于通过Java传输客户端使用的内部传输协议访问Elasticsearch。检查你的防火墙设置,可能被防火墙阻止。