简体   繁体   English

NoNodeAvailableException : 没有配置的节点可用

[英]NoNodeAvailableException : None of the configured nodes are available

I'm trying to search from Elastic Search within my Java Web Service, here's how I use now :我正在尝试从我的 Java Web 服务中的 Elastic Search 进行搜索,这是我现在的使用方式:

    Client client = new PreBuiltTransportClient(Settings.EMPTY).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.10.150"), 9200));
    SearchResponse searchResponse = client.prepareSearch().execute().actionGet();

The 1st line could work without an error, but when it goes to the 2nd line, the exception down below will occur :第一行可以正常工作,但当它转到第二行时,将发生下面的异常:

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{TskPSVeBRR6CvCzP9EVhkQ}{192.168.10.150}{192.168.10.150:9200}]] NoNodeAvailableException[没有配置的节点可用:[{#transport#-1}{TskPSVeBRR6CvCzP9EVhkQ}{192.168.10.150}{192.168.10.150:9200}]]

No matter I use 9200 or 9300 to set the port , the results are the same.不管我用9200还是9300设置端口,结果都是一样的。

Also, I've tried to search from my .Net program using NEST , and it run just fine.另外,我尝试使用NEST从我的.Net程序中进行搜索,并且它运行得很好。 Here's how I tried :这是我尝试的方法:

    var node = new Uri("http://192.168.10.150:9200");
    var settings = new ConnectionSettings(node).DefaultIndex("iod-2017.03.08.*");
    _EsClient = new ElasticClient(settings);
    var index = String.Format("iod-{0}.{1:00}.{2:00}.*", item.TriggerTime.Year, item.TriggerTime.Month, item.TriggerTime.Day);
    var uniqueId = item.UniqueId.ToString();
    var result = _EsClient.Search<logs>(s => s.Index(index).Query(q => q.Match(t => t.Field(l => l.id).Query(uniqueId))));

Did I do anything( Firewall , version of library, method to call the API, etc) wrong with my Java program?我的 Java 程序是否有任何错误(防火墙、库版本、调用 API 的方法等)? My current Java version is 1.8.0.121 , the version of Elastic Search and Transport Client are both 5.2 .我当前的Java版本是1.8.0.121Elastic SearchTransport Client的版本都是5.2 Thanks!谢谢!

As discussed in comments,正如评论中所讨论的,

If you are using a cluster name other than elasticsearch , then you need to update the same in settings.如果您使用的集群名称不是elasticsearch ,那么您需要在设置中更新相同的名称。

Settings settings = Settings.builder()
        .put("cluster.name", "myClusterName").build();

I was facing the same issue, my cluster name & everything were correct, but my elastic cluster was using X-Pack Security.我遇到了同样的问题,我的集群名称和一切都是正确的,但我的弹性集群使用的是 X-Pack Security。 And it was only because of that.而也正是因为如此。

Here is solutions - https://www.elastic.co/guide/en/x-pack/current/java-clients.html这是解决方案 - https://www.elastic.co/guide/en/x-pack/current/java-clients.html

From documentation,从文档来看,

// on startup

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300)); 

If you are install elasticsearch from extracted file (eg: elasticsearch-5.4.0.tar.gz), please try to install it in through yum or other RPM tool.如果您是从解压文件中安装elasticsearch(例如:elasticsearch-5.4.0.tar.gz),请尝试通过yum 或其他RPM 工具安装。 https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html It help me solve this problem. https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html它帮助我解决了这个问题。

Before executing the program make sure you ran the elasticSearch.bat batch file present under ElasticSearch -> config folder .在执行程序之前,请确保您运行了ElasticSearch -> config folder下的elasticSearch.bat批处理文件。 Also make sure you see "started" logged in the console where you ran the batch file.还要确保在运行批处理文件的控制台中看到“已启动”记录。

You can check if elastic search started successfully or not by hitting the URL localhost:9200 .您可以通过点击 URL localhost:9200来检查弹性搜索是否成功启动。 You should see a page looking something like this:你应该看到一个看起来像这样的页面:

{
  "name" : ...,
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : ...,
  "version" : {
    "number" : "5.5.2",
    ...
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

Add the cluster name as a parameter on the connection URI:添加集群名称作为连接 URI 上的参数:

  1. Go to http://<elasticsearch_host>:9200转到http://<elasticsearch_host>:9200
  2. Retrieve the cluster_name value and add it as a parameter to the connection URI: elasticsearch://<elasticsearch_host>:9300?cluster.name=<cluster_name_value>检索cluster_name值并将其作为参数添加到连接 URI: elasticsearch://<elasticsearch_host>:9300?cluster.name=<cluster_name_value>

This Exception is pointing to elasticSearch transport client is not able to establish a connection with elasticsearch server.此异常指向 elasticSearch 传输客户端无法与 elasticsearch 服务器建立连接。

Root cause might be the port name or IP/hostname of server OR cluster Name OR Authentication is incorrect.根本原因可能是服务器的端口名称或 IP/主机名或集群名称或身份验证不正确。

Open elasticSearch.yaml file and validate all details correctly.打开 elasticSearch.yaml 文件并正确验证所有详细信息。 To ignore clusterName validation by using the following configuration params.使用以下配置参数忽略 clusterName 验证。

client.transport.ignore_cluster_name = true

Full code snippet to create transport Client is:创建传输客户端的完整代码片段是:

 Settings settingsBuilder = Settings.builder()
            .put("cluster.name", DBPropertyUtil.getPropertyByName("es.cluster")).put("client.transport.sniff", true).put("client.transport.ignore_cluster_name", true).build();
            //.put("client.transport.sniff", true).put("path.home", ".").build();
         Client client = new PreBuiltTransportClient(settingsBuilder)
            .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));

Specify host and port as per your server.根据您的服务器指定主机和端口。 This code is working fine for me.这段代码对我来说很好用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NoNodeAvailableException [没有已配置的节点可用]在Elasticsearch 5.1.2中 - NoNodeAvailableException[None of the configured nodes are available] in Elasticsearch 5.1.2 Elasticsearch NoNodeAvailableException没有配置的节点可用 - Elasticsearch NoNodeAvailableException None of the configured nodes are available 无法在TransportClient中创建InetSocketTransportAddress:NoNodeAvailableException [没有配置的节点 - 可用:[]] - Can't create InetSocketTransportAddress in TransportClient: NoNodeAvailableException[None of the configured nodes -are available: []] org.elasticsearch.client.transport.NoNodeAvailableException:没有配置的节点可用:[] - org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [] NoNodeAvailableException [没有配置的节点可用:[{#transport#-1} {...} {127.0.0.1} {127.0.0.1:9300}]] - NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{…}{127.0.0.1}{127.0.0.1:9300}]] NoNodeAvailableException[没有配置的节点可用:[{#transport#-1}{XY6cYmf7Sn-DRZgzeq3PBA}{localhost}{127.0.0.1:9300}]] - NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{XY6cYmf7Sn-DRZgzeq3PBA}{localhost}{127.0.0.1:9300}]] NoNodeAvailableException[没有配置的节点可用:[{#transport#-1}{OqtopIzTQmOjjLBzr2G_JA}{127.0.0.1}{127.0.0.1:9300}]] - NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{OqtopIzTQmOjjLBzr2G_JA}{127.0.0.1}{127.0.0.1:9300}]] Java ElasticSearch 没有配置的节点可用 - Java ElasticSearch None of the configured nodes are available 无法连接到Elasticsearch 6.1.0 [没有已配置的节点可用] - Unable to Connect to Elasticsearch 6.1.0[None of the configured nodes are available] Java Elasticsearch-Hadoop没有配置的节点可用 - Java Elasticsearch-Hadoop None of the configured nodes are available
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM