elasticsearch報 NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1
阿新 • • 發佈:2019-02-15
es版本 :6.3.1
jdk 1.8
elasticsearch 連線報:
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{GRphuiRLRgOVTP0707mGFQ}{192.168.11.216}{192.168.11.216:9200}]] at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60) at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:378) at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:405) at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:394) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46) at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:53) at com.es.test.EsTest.addIndex1(EsTest.java:70) at com.es.test.EsTest.main(EsTest.java:89)
解決方法:
修改es配置檔案(elasticsearch-2.3.3\config\elasticsearch.yml),
修改network.host
network.host:伺服器IP地址
補充說明:
如果你的java程式碼連線方式為下面的程式碼,要在配置檔案中存在此結點。
Settings settings = Settings.settingsBuilder().put("cluster.name","my-application").put("client.transport.sniff", true).build();
client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ipAddress1), iPort1));
注意一下,cluster.name在es配置檔案(elasticsearch\config\elasticsearch.yml)存在。
然後,特別注意
java埠9300,http埠9200
不要把 9200 埠放程式碼中去連線...