没有可用的节点elasticsearch

时间:2018-07-15 12:34:22

标签: java elasticsearch search

我在项目中使用elasticsearch。但是,当在服务器上部署项目时,它会出现异常,我读了其他相同的问题,但没有找到解决方案: 我将端口更改为9300,但仍未解决。

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{EEv7PPi1SYqxodHCtCrfEw}{192.168.0.253}{192.168.0.253:9200}]]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:344)
        at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:242)
        at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)

这是我在代码中对elasticsearch的配置:

 public static void postConstruct() {
            try {
                Settings settings = Settings.builder()
                        .put("cluster.name","my-application").build();
                client = new PreBuiltTransportClient(settings)
                        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(Bundle.application.getString("ELASTIC_ADDRESS")), Integer.parseInt(Bundle.application.getString("9200"))));
                try {
                    client.admin().indices().prepareCreate("tempdata").get();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } catch (UnknownHostException e) {
                e.printStackTrace();
            }
        }

我的项目中和服务器上的elasticsearch bot版本是相同的。这就是我卷曲'http://x.x.x.x:9200/?pretty'

时得到的
{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "5.2.2",
    "build_hash" : "f9d9b74",
    "build_date" : "2017-02-24T17:26:45.835Z",
    "build_snapshot" : false,
    "lucene_version" : "6.4.1"
  },
  "tagline" : "You Know, for Search"
}

当我将端口更改为9300时,几秒钟后,我看到的异常是这样的:

MasterNotDiscoveredException[null]
        at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$4.onTimeout(TransportMasterNodeAction.java:211)
        at org.elasticsearch.cluster.ClusterStateObserver$ContextPreservingListener.onTimeout(ClusterStateObserver.java:307)
        at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:237)
        at org.elasticsearch.cluster.service.ClusterService$NotifyTimeout.run(ClusterService.java:1157)

这是elasticsearch的日志,我不知道什么是host1和host2:

   [2018-07-16T15:40:59,476][DEBUG][o.e.a.a.i.g.TransportGetIndexAction] [gCJIhnQ] no known master node, scheduling a retry
[2018-07-16T15:41:29,478][DEBUG][o.e.a.a.i.g.TransportGetIndexAction] [gCJIhnQ] timed out while retrying [indices:admin/get] after failure (timeout [30s])
[2018-07-16T15:41:29,481][WARN ][r.suppressed             ] path: /bad-request, params: {index=bad-request}
org.elasticsearch.discovery.MasterNotDiscoveredException: null
        at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$4.onTimeout(TransportMasterNodeAction.java:211) [elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.cluster.ClusterStateObserver$ContextPreservingListener.onTimeout(ClusterStateObserver.java:307) [elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:237) [elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.cluster.service.ClusterService$NotifyTimeout.run(ClusterService.java:1157) [elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:527) [elasticsearch-5.2.2.jar:5.2.2]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_91]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_91]

1 个答案:

答案 0 :(得分:2)

由于评论的数量增加了,因此以下提示可能会有所帮助。我假设您使用的是一个独立的Elasticsearch实例,该实例以ES_HOME / bin / elasticsearch作为服务器计算机上的主节点启动。

  1. 确保在配置为主节点的服务器上的elasticsearch。有关Elasticsearch中节点的更多详细信息,请参见https://www.elastic.co/guide/en/elasticsearch/reference/6.3/modules-node.html
  2. 确保服务器上的elasticsearch绑定到非环回地址。有关此的详细信息,请参阅https://www.elastic.co/guide/en/elasticsearch/reference/current/network.host.html
  3. 检查传输客户端版本与服务器版本是否兼容。
  4. 按照他们所说的here来增加mmap计数。在Linux中,通过运行以下命令:sysctl -w vm.max_map_count = 262144
  5. 检查服务器上的传输端口号,该端口可以从外部访问。默认为9300-9400
  6. 检查服务器上的elasticsearch服务日志,以确保其配置与您一样!