1.問題描述
ES client客戶端能創建,但是在用客戶端操作時報:NoNodeAvailableException[None of the configured nodes are available:[{#transport#-1}{XXXXX}{ip:port}]]。
該問題是客戶端無法連接至es服務器,從以下角度排查。
2.解決方案
2.1. 查看配置的ip和端口號是否正確,端口號需要配置tcp端口
2.2 查看cluster name是否正確
2.3 使用的es client版本需要與ES Server版本一致
2.4 如果是運行一段時間后出現的問題,則可能是某個鏈接的節點出問題了,這時es會自動切換到其他節點訪問
2.5 測試環境和生產環境不同,不要拿測試機器訪問生產環境
2.6 如果集群開啟了訪問鑒權,將用戶名,密碼傳入
2.7 client.transport.sniff設置成false,ip:port通過addTransportAddress傳入
2.8 netty包沖突,直接引入es client用的netty包版本:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.16.Final</version>
</dependency>
我的es client是6.3.2用的netty是4.1.6,將其余沖突包中的netty排除:
<exclusion>
<artifactId>netty-all</artifactId>
<groupId>io.netty</groupId>
</exclusion>
按照上述排查,應該能解決問題。