Elasticsearch - NoNodeAvailableException [英] Elasticsearch - NoNodeAvailableException

查看:33
本文介绍了Elasticsearch - NoNodeAvailableException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用 ES 2 的 Java API 连接到 Elasticsearch 2 时出现以下错误.这是代码:

I get the following error when trying to connect to Elasticsearch 2 using the Java API for ES 2. This is the code:

Settings settings = Settings.settingsBuilder().put("cluster.name", Receptor.clusterName).build();
TransportClient transportClient = TransportClient.builder().settings(settings).build();
Client c = null;
try {
     c = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(Receptor.es_ip), 9300));
} catch (UnknownHostException e) {
     System.err.println(Util.getTimestampStr() + "UnknownHostException error.");
     e.printStackTrace();
}

CreateIndexRequestBuilder createIndexRequestBuilder = c.admin().indices().prepareCreate(indexName);
createIndexRequestBuilder.addMapping(documentName, json);
createIndexRequestBuilder.execute().actionGet();

我可以在 transportClient.connectedNodes() 上获取我的 ES 节点,但是当我尝试添加新映射时,我收到了 NoNodeAvailableException 异常.此代码适用于以前版本的 Elasticsearch.知道出了什么问题吗?

I'm able to get my ES node on the transportClient.connectedNodes() but when I try to add a new mapping I get the NoNodeAvailableException exception. This code worked with previous versions of Elasticsearch. Any idea of what's wrong?

NoNodeAvailableException[None of the configured nodes are available:
[]]     at
org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:280)
    at
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
    at
org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
    at
org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
    at
org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
    at
org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1177)
    at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
    at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)

推荐答案

@AndreiStefan 感谢 他的帖子解决了我的问题链接.解决方案非常简单:

@AndreiStefan gave the solution to my problem thanks to the post he linked. The solution was as straightforward as:

network.bind_host: 0

谢谢你们.

这篇关于Elasticsearch - NoNodeAvailableException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆