一:
javaApi通过tcp9300调用es集群,遇到的问题。
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{xT4bF9ImTUiamYI9VJxKUA}{39.96.53.24}{39.96.53.24:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:351)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:249)
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 cn.example.DocumentDemo.main(DocumentDemo.java:121)
一步步debug发现是,发现集群时产生的报错。暂时先注释掉( .put("client.transport.sniff", true) )。
Settings esSettings = Settings.builder()
.put("cluster.name", clusterName)
// .put("client.transport.sniff", true)// 自动嗅探整个集群状态,把其他ES节点ip添加到客户端。
.build();