在使用elasticsearch时报错:
[None of the configured nodes are available: [{#transport#-1}{wXgtIC2KRUyygVQIJeSrFA}{127.0.0.1}{127.0.0.1:9300}]]
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{wXgtIC2KRUyygVQIJeSrFA}{127.0.0.1}{127.0.0.1:9300}]]
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:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
原因1:spring-data-elasticsearch与elasticsearch版本不匹配,版本不一致将会导致报错。
原因2:配置文件elasticsearch.yml中cluster.name与项目里的不一致会导致报错。
修改elasticsearch.yml时一定要注意使用utf-8编码,英文编写,不然修改过后启动会出现闪退的情况。
修改后elasticsearch.yml:
springboot中,本人使用的properties方式配置,springboot中使用yml同理。:
spring.data.elasticsearch.cluster-name=my-application
原因3:如果还不行检查配置文件中节点是否为9300。
9200作为Http协议,主要用于外部通讯
9300作为Tcp协议,jar之间就是通过tcp协议通讯
ES集群之间是通过9300进行通讯