NoNodeAvailableException
2019-11-05 本文已影响0人
站在海边看远方
elasticsearch版本:6.8.3
使用java客户端和es进行交互的时候,抛了如下异常:
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{kRDWAYuFSJmGx-tcjB0L1g}{172.16.17.10}{172.16.17.10:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:352)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:248)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:388)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:391)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:53)
at com.fc.elastic.TestElastic.main(TestElastic.java:49)
先说结果:
1先修改es server端的elasticsearch.yml配置文件
network.host: 0.0.0.0
network.bind_host: 172.16.17.10
http.cors.enabled: true
http.cors.allow-origin: "*"
bind_host是部署es服务端的机器ip.
http和tcp端口使用了默认值,9200和9300,集群名称使用了默认的集群名称
做如上修改可以解决这个异常问题。
2. 其他配置排查
- cluster.name 客户端与服务端配置是否相同
- 使用的端口是否是tcp端口,java客户端与server端交互是使用tcp端口,默认9300