转载

NoNodeAvailableException[None of the configured nodes are available

在使用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版本不匹配,版本不一致将会导致报错。

springboot 2.1.6 对应 Elasticsearch 6.3.2
springboot 2.2.5 对应 Elasticsearch 7.6.0
springboot 2.2.6 对应 Elasticsearch 7.7.0

原因2:配置文件elasticsearch.yml中cluster.name与项目里的不一致会导致报错。

修改elasticsearch.yml时一定要注意使用utf-8编码,英文编写,不然修改过后启动会出现闪退的情况。
修改后elasticsearch.yml:

springboot中,本人使用的properties方式配置,springboot中使用yml同理。:

spring.data.elasticsearch.cluster-name=elasticsearch

原因3:如果还不行检查配置文件中节点是否为9300。

# elasticsearch.yml 集群名字
spring.data.elasticsearch.cluster-name=elasticsearch
# elasticsearch tcp通信地址
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300

9200作为Http协议,主要用于外部通讯

9300作为Tcp协议,jar之间就是通过tcp协议通讯

ES集群之间是通过9300进行通讯

 

正文到此结束
Loading...