迦南Besos 2024-04-10 00:01 采纳率: 0%
浏览 4

elasticsearch报错

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{IwNecF7LRCGevaJe61kiCQ}{127.0.0.1}{127.0.0.1:9300}]
]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.getSearchResponse(ElasticsearchTemplate.java:937)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.doSearch(ElasticsearchTemplate.java:928)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.queryForPage(ElasticsearchTemplate.java:308)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.queryForPage(ElasticsearchTemplate.java:303)
at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.queryForPage(ElasticsearchTemplate.java:133)
at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.search(AbstractElasticsearchRepository.java:214)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359)
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)

  • 写回答

4条回答 默认 最新

  • Kwan的解忧杂货铺 2024-04-10 00:01
    关注

    上午好☀️☀️☀️️
    本答案参考ChatGPT-3.5

    这个错误是由于 Elasticsearch 客户端无法连接到可用的节点引起的。出现此错误可能有以下原因:

    1.节点故障或关闭。

    2.客户端配置错误。

    要解决此错误,可以尝试以下解决方案:

    1.检查 Elasticsearch 节点是否已启动。

    2.通过 ping 命令或 telnet 命令检查 Elasticsearch 节点是否可访问。

    3.检查 Elasticsearch 客户端配置是否正确。

    4.升级 elasticsearch 运行环境中的 java jdk 版本。

    5.检查 elasticsearch、jar 包是否对应。

    6.判断 Elasticsearch 版本和 Spring Boot 版本是否兼容,如果不兼容可能需要降级 Elasticsearch 版本或者升级 Spring Boot 版本。

    修改后的代码:

    在 Spring Boot 配置文件中,添加以下配置:

    elasticsearch.cluster-name=my_cluster_name elasticsearch.host-1=127.0.0.1:9300 elasticsearch.host-2=127.0.0.1:9301 elasticsearch.host-3=127.0.0.1:9302

    在 Java 代码中配置 Elasticsearch 客户端:

    @Configuration public class ElasticsearchConfig {

    @Value("${elasticsearch.cluster-name}")
    private String clusterName;
    
    @Value("${elasticsearch.host-1}")
    private String host1;
    
    @Value("${elasticsearch.host-2}")
    private String host2;
    
    @Value("${elasticsearch.host-3}")
    private String host3;
    
    @Bean
    public TransportClient transportClient() throws UnknownHostException {
        Settings settings = Settings.builder()
                .put("cluster.name", clusterName)
                .put("client.transport.sniff", true)
                .build();
    
        TransportClient client = new PreBuiltTransportClient(settings)
                .addTransportAddress(new TransportAddress(InetAddress.getByName(host1.split(":")[0]), Integer.parseInt(host1.split(":")[1])))
                .addTransportAddress(new TransportAddress(InetAddress.getByName(host2.split(":")[0]), Integer.parseInt(host2.split(":")[1])))
                .addTransportAddress(new TransportAddress(InetAddress.getByName(host3.split(":")[0]), Integer.parseInt(host3.split(":")[1])));
    
        return client;
    }
    

    }

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 4月10日

悬赏问题

  • ¥30 为什么会失败呢,该如何调整
  • ¥50 如何在不能联网影子模式下的电脑解决usb锁
  • ¥20 服务器redhat5.8网络问题
  • ¥15 如何利用c++ MFC绘制复杂网络多层图
  • ¥20 要做柴油机燃烧室优化 需要保持压缩比不变 请问怎么用AVL fire ESE软件里面的 compensation volume 来使用补偿体积来保持压缩比不变
  • ¥15 python螺旋图像
  • ¥15 算能的sail库的运用
  • ¥15 'Content-Type': 'application/x-www-form-urlencoded' 请教 这种post请求参数,该如何填写??重点是下面那个冒号啊
  • ¥15 找代写python里的jango设计在线书店
  • ¥15 请教如何关于Msg文件解析