Elasticsearch 5 Java Client 给出 “NoNodeAvailableException”
2022-09-04 22:17:39
我正在使用Elasticsearch 5.2和Spring Boot 1.5.1。我正在通过Spring应用程序中的Java客户端连接到它。当我在端口上连接到它或我得到.在我的Java客户端中,我已将属性设置为.通过端口 9200 上的 cURL 向其发送请求时,它工作正常。我在单个群集中有 4 个节点,我无法连接到其中任何一个节点。我的配置文件具有除法中的所有默认值,但其中的默认值除外。9300
9200
NoNodeAvailableException: None of the configured nodes are available
client.transport.sniff
true
network
network.host
eth0
inet addr
我正在使用Gradle。我的依赖关系是:
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.elasticsearch:elasticsearch:5.2.0')
compile('org.elasticsearch.client:transport:5.2.0')
compile('org.apache.logging.log4j:log4j-api:2.7')
compile('org.apache.logging.log4j:log4j-core:2.7')
我用于连接到 Elasticsearch 集群的代码:
@Bean
public TransportClient elasticClient() {
org.elasticsearch.common.settings.Settings settings = Settings.builder()
.put("client.transport.sniff", true)
.put("cluster.name", "TestCluster")
.build();
TransportClient client = null;
try {
client = new org.elasticsearch.transport.client.PreBuiltTransportClient(settings)
.addTransportAddress(new org.elasticsearch.common.transport.InetSocketTransportAddress(
InetAddress.getByName("54.175.155.56"), 9200));
} catch (UnknownHostException e) {
e.printStackTrace();
}
return client;
}
ES 启动时我的 ES 日志是:
[2017-02-15T10:37:40,664][INFO ][o.e.t.TransportService ] [ip-10-0-29-2] publish_address {10.0.29.2:9300}, bound_addresses {10.0.29.2:9300}
[2017-02-15T10:37:40,669][INFO ][o.e.b.BootstrapChecks ] [ip-10-0-29-2] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-02-15T10:37:43,856][INFO ][o.e.c.s.ClusterService ] [ip-10-0-29-2] detected_master {kafka-stage}{sTIeF8gGTNam0oNW8dkbbA}{TTX6FIRtRp-gDemYY-22Sg}{10.0.20.71}{10.0.20.71:9300}, added {{kafka-stage-2}{jl3oLGgMQ1yxhdMMy65k_g}{ibV8BApjRByUOpDDncddyQ}{10.0.51.31}{10.0.51.31:9300},{ip-10-0-40-144}{t-_THs3wQbC_k9eivDo5eQ}{v-UYoYgXQ265QkdYhtiPYA}{10.0.40.144}{10.0.40.144:9300},{kafka-stage}{sTIeF8gGTNam0oNW8dkbbA}{TTX6FIRtRp-gDemYY-22Sg}{10.0.20.71}{10.0.20.71:9300},}, reason: zen-disco-receive(from master [master {kafka-stage}{sTIeF8gGTNam0oNW8dkbbA}{TTX6FIRtRp-gDemYY-22Sg}{10.0.20.71}{10.0.20.71:9300} committed version [98]])
[2017-02-15T10:37:44,009][INFO ][o.e.h.HttpServer ] [ip-10-0-29-2] publish_address {10.0.29.2:9200}, bound_addresses {10.0.29.2:9200}
[2017-02-15T10:37:44,009][INFO ][o.e.n.Node ] [ip-10-0-29-2] started
这些问题的答案并不能解决我的问题: