【问题标题】:None of the configured nodes are available: [{#transport#-1}{6cirTCG_SJW0yPPONMB-HQ}{localhost}{127.0.0.1:9300}]配置的节点都不可用:[{#transport#-1}{6cirTCG_SJW0yPPONMB-HQ}{localhost}{127.0.0.1:9300}]
【发布时间】:2019-12-16 20:01:11
【问题描述】:

Elastic Search 配置如下:

import java.net.InetAddress;

@Configuration
@EnableElasticsearchRepositories
public class ElasticSearchConfig {

    @Value("localhost")
    private String host;

    @Value("9300")
    private int port;

    @Value("elasticsearch")
    private String clusterName;

    @Bean
    public Client client() throws Exception {

        Settings esSettings = Settings.builder()
                .put("cluster.name", clusterName)
                .put("node.name", "node-1")
                .put("node.attr.rack","r1")
                .put("client.transport.sniff", true)
                .build();

        TransportClient transportClient = new PreBuiltTransportClient(esSettings);
        transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName(host),port));
        return transportClient;
    }

   /* @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(client());
    }*/
}

我收到以下异常:

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{6cirTCG_SJW0yPPONMB-HQ}{localhost}{127.0.0.1:9300}]]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:349)
        at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:247)
        at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
        at 

请推荐

我尝试启用所有不同的属性,例如 client.transport.sniffing、node.attr.rack 等。我在 elasticsearch.yml 中启用了所有这些属性

【问题讨论】:

  • 为什么要创建传输客户端,可以使用高级别的客户端吗?/
  • 端口 9300 用于 ES 节点通信。我们应该使用 9200 与 Elasticsearch 交互。
  • 您的集群是如何设置的?以及您使用哪个版本的弹性搜索?它是否在本地主机和端口 9300 上运行?您使用哪个版本的 Spring Data Elasticsearch?
  • @SathishkumarRakkiasamy 9300 也适用于使用传输客户端,尽管它在 ES 7 中已被弃用,但仍然可用。

标签: spring-boot elasticsearch spring-data-elasticsearch


【解决方案1】:

尝试将端口从 9300 更改为 9200。根据文档,您正在使用的软件包将来也会被弃用。请尝试使用功能丰富且支持良好的High Level REST Client。更多详情refer this link

当您为 elasticsearch 集群设置多节点(单主多数据)时,端口 9300 供 ES 节点相互通信。我们应该使用 9200 与 Elasticsearch 交互。

【讨论】:

  • 传输客户端自 Elasticsearch 7 起已弃用,并将在版本 8 中删除。对于 Spring Data Elasticsearch,它将在下一个版本 4.0 中得到支持 - 尽管在那里也已弃用 - 然后可能会在版本 5 中删除。
猜你喜欢
  • 1970-01-01
  • 2020-07-19
  • 1970-01-01
  • 1970-01-01
  • 2015-11-23
  • 2017-08-07
  • 2014-11-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多