java操作elasticsearch出现:NoNodeAvailableException[None of the configured nodes are available
使用java练习操作elasticsearch创建索引的时候报了个这个异常抛出错误 :NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}NoNodeAvailableException[None of the configured nodes are available:[{#t
·
使用java练习操作elasticsearch创建索引的时候报了个这个异常
抛出错误 :NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}
NoNodeAvailableException[None of the configured nodes are available:
[{#transport#-1}{X9CRqw6oRCW_Plhej_83zA}{127.0.0.1}{127.0.0.1:9301},
{#transport#-2}{lIXhzlodQdeAlMt91H1iSg}{127.0.0.1}{127.0.0.1:9302},
{#transport#-3}{cn6mD-gKSsCXiqOyirjEEg}{127.0.0.1}{127.0.0.1:9303}]
]
解决办法
多半情况下是因为elasticsearch\config\elasticsearch.yml里面的cluster.name,network.host,node.name没有配置或者配置跟用java(或者在你的application.xml/yml里面)创建的时候填写的参数不一致造成的,可以到elasticsearch.yml里面进行修改
注意!!不管你在elasticsearch.yml更改了什么,改完后一定要重启elasticsearch客户端也就是elasticsearch.bat,不然你做的更改就不会生效!!
这里把我自己的一些配置写在这供大家参考
#集群名称配置
cluster.name: my-elasticsearch
#集群ip为本机ip
network.host: 127.0.0.1
#节点名称
node.name: node-1
#服务端口号
http.port: 9201
#集群间通信端口号
transport.tcp.port: 9301
#设置集群自动发现端口集合
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"]
如果更改完成后依然报错,那可能就是版本冲突问题
导入的依赖最好和es的版本一致,我这里的es是5.6.8版本
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.6.8</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.6.8</version>
</dependency>
更改完成即可。
更多推荐
已为社区贡献1条内容
所有评论(0)