启动SpringData Elasticsearch 服务报错
2020-04-18 10:03:26.233 ERROR 3016 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{VNoxRLKKSLO_yIQFBYhn9Q}{192.168.0.105}{192.168.0.105:9200}]
在Xshel中
java.io.IOException: 连接被对方重设
at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[?:?]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[?:?]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:?]
at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[?:?]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[?:?]
原因:
ElasticSearch启动时,会占用两个端口9200和9300。
- 9200 是ES节点与外部通讯使用的端口。它是http协议的RESTful接口,各种CRUD操作都是走的该端口
- 9300是ES节点之间通讯使用的端口。它是tcp通讯端口,集群间和TCPclient都用此接口。
所以Java程序中使用ES时,在配置文件中要配置9300端口
把 cluster-nodes:192.163.0.105:9200 改为 192.163.0.105:9300 解决问题