报错:
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{wvf0HEOpRFOFC-7JCynuSQ}{192.168.126.130}{192.168.126.130:9300}] ]
springboot的配置文件:
spring.data.elasticsearch.cluster-name=elasticsearch spring.data.elasticsearch.cluster-nodes=192.168.126.130:9300分析原因:
docker下安装的es默认集群名字为"docker-cluster", 而API 中不指定集群名的话, 默认为elasticsearch,
解决(此时不一定能解决,往下)
修改elasticsearch.yml文件中指定cluster名字
参考:https://blog.csdn.net/zhengjian0617/article/details/83149926
进入elasticsearch.yml
# 进入es1 docker exec -it es1 bash # 编辑config目录下的elasticsearch.yml vi config/elasticsearch.yml参考:https://www.jianshu.com/p/991c74a1bbf7
如果vi进入不了:
bash: vi: command not found 安装vim apt-get update apt-get install vim上面修同了cluster.name 后仍然报相同错误,继续配置elasticsearch.yml
(若是其他错误,请先检查自己整合的配置文件是否正确)
继续配置,参考:https://www.cnblogs.com/sxdcgaq8080/p/10031744.html
建议如果默认network.host: 0.0.0.0, 而自己没有特殊要求不要去修改
我的elastisearch.yml
cluster.name: elasticsearch node.name: "tan" node.master: true network.host: 0.0.0.0 transport.tcp.port: 9300 http.port: 9200然后ok了。