项目场景:

项目使用了ElasticSearch【后续简称Es】,配置了Es的相关配置,通过spring的健康检查端点判断服务运行情况。项目未通过reactor的方式使用Es。


问题描述:

系统配置文件配置如下:

​​spring:elasticsearch:rest:uris: http://xxxx:9200,http://xxxx:9200,http://xxxx:9200username: elasticpassword: ${pwd.elastic}

调用/actuator/health,发现状态为DOWN。控制台报错如下:

2021-06-23 11:32:32.827  WARN [] 30680 --- [ctor-http-nio-2] a.e.ElasticsearchReactiveHealthIndicator : Elasticsearch health check failedorg.springframework.data.elasticsearch.client.NoReachableHostException: Host 'localhost:9200' not reachable. Cluster state is offline.at org.springframework.data.elasticsearch.client.reactive.SingleNodeHostProvider.lambda$null$4(SingleNodeHostProvider.java:106)

原因分析:

从报错上看,这个健康检查明显使用的是响应式的健康检查。

通过debug发现host是localhost,并非配置文件中配置的地址:

client中的host配置是通过下面的配置进行配置的:

spring:data:elasticsearch:client:reactive:endpoints: http://xxxx:9200,http://xxxx:9200,http://xxxx:9200username: elasticpassword: ${pwd.elastic}

配置上之后可以解决控制台报错,但是调用/actuator/health 会卡死。

继续排查:

从堆栈上看出这个bean是通过ElasticSearchReactiveHealthContributorAutoConfiguration 注入的:

package org.springframework.boot.actuate.autoconfigure.elasticsearch;import java.util.Map;
import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthContributorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.elasticsearch.ElasticsearchReactiveHealthIndicator;
import org.springframework.boot.actuate.health.ReactiveHealthContributor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRestClientAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import reactor.core.publisher.Flux;@Configuration(proxyBeanMethods = false
)
@ConditionalOnClass({ReactiveElasticsearchClient.class, Flux.class})
@ConditionalOnBean({ReactiveElasticsearchClient.class})
@ConditionalOnEnabledHealthIndicator("elasticsearch")
@AutoConfigureAfter({ReactiveElasticsearchRestClientAutoConfiguration.class})
public class ElasticSearchReactiveHealthContributorAutoConfiguration extends CompositeReactiveHealthContributorConfiguration<ElasticsearchReactiveHealthIndicator, ReactiveElasticsearchClient> {public ElasticSearchReactiveHealthContributorAutoConfiguration() {}@Bean@ConditionalOnMissingBean(name = {"elasticsearchHealthIndicator", "elasticsearchHealthContributor"})public ReactiveHealthContributor elasticsearchHealthContributor(Map<String, ReactiveElasticsearchClient> clients) {return (ReactiveHealthContributor)this.createContributor(clients);}
}

也就是项目只要依赖的Flux相关的的内容就会创建这个bean。同时项目中也有:

org.springframework.boot.actuate.autoconfigure.elasticsearch.ElasticSearchRestHealthContributorAutoConfiguration

这里会注入rest方式的健康检查bean。

两者同时存在时,健康检查取用了响应式的检查类。


解决方案:

从上面的分析可以看出解决办法有两个:

方案1、排除Flux相关依赖;

方案2、排除ElasticSearchReactiveHealthContributorAutoConfiguration。

我这采用的第二种,在启动类中排除该依赖即可:

@SpringBootApplication(exclude=ElasticSearchReactiveHealthContributorAutoConfiguration.class)

ElasticSearch健康检查localhost:9200 not reachable相关推荐

  1. 安装Kibana报错[warning][admin][elasticsearch] Unable to revive connection: http://localhost:9200/

    实验环境 : Ubuntu 160.4 Kibana :kibana-6.2.3 报错信息 : log [07:23:26.511] [warning][admin][elasticsearch] N ...

  2. Docker 容器健康检查机制

    摘要: 在分布式系统中,经常需要利用健康检查机制来检查服务的可用性,防止其他服务调用时出现异常.自 1.12 版本之后,Docker 引入了原生的健康检查实现.本文将介绍Docker容器健康检查机制, ...

  3. 如何在 ASP.Net Core 中实现 健康检查

    健康检查 常用于判断一个应用程序能否对 request 请求进行响应,ASP.Net Core 2.2 中引入了 健康检查 中间件用于报告应用程序的健康状态. ASP.Net Core 中的 健康检查 ...

  4. 聊聊Spring Boot服务监控,健康检查,线程信息,JVM堆信息,指标收集,运行情况监控等!...

    来自:https://juejin.im/post/5e2179def265da3e152d2561 前言 去年我们项目做了微服务1.0的架构转型,但是服务监控这块却没有跟上.这不,最近我就被分配了要 ...

  5. Spring Boot 服务监控,健康检查,线程信息,JVM堆信息,指标收集,运行情况监控...

    作者:Richard_Yi 来源:http://39sd.cn/B2A0B 去年我们项目做了微服务1.0的架构转型,但是服务监控这块却没有跟上.这不,最近我就被分配了要将我们核心的微服务应用全部监控起 ...

  6. 运维企业专题(8)LVS高可用与负载均衡后篇——LVS健康检查与高可用详解

    实验准备 1.下面的实验使用的是rhel6系列(rhel6.5)的虚拟机,因此你需要有对应的镜像和yum源 2.准备三台虚拟机,为了区分主机名与IP分别为 server1 172.25.6.1 ser ...

  7. Docker 健康检查功能

    Docker1.12及以上版本,自带了健康检查功能.通常情况下只能使用docker ps 来查看容器是否是up的状态,但是服务是否正常我们不可知,而健康检查功能,可以允许我们在容器中执行一些健康检查的 ...

  8. 服务器状态显示down,Eureka心跳健康检查机制和Spring boot admin 节点状态一直为DOWN的排查(忽略某一个节点的健康检查)...

    运行阶段执行健康检查的目的是为了从Eureka服务器注册表中识别并删除不可访问的微服务,Eureka 服务器并不是向客户端发送心跳请求,而是反过来,Eureka 客户端将心跳发送到Eureka服务器, ...

  9. 【Consul】Consul实践指导-健康检查(Checks)

    Consul的一个基本功能是提供系统级和应用级健康检查.如果健康检查与某个服务关联,则称为是应用级的:如果不予服务关联,则监控整个节点的健康. check定义在配置文件中,或运行时通过HTTP接口添加 ...

最新文章

  1. 平滑迁移 Dubbo 服务的思考
  2. C++ 20 是近十年来影响最大的一个版本,新的特性众多
  3. 22:00直播|当加班男程序猿 被美女主播~ 捕到后...
  4. DCMTK:将DICOM结构化报告文件的内容转换为XML格式
  5. oracle备份和还原
  6. win10右键闪退到桌面_WIN10设置闪退,桌面右键个性化显示设置等均无效
  7. 第九节--绑定 -- Classes and Objects in PHP5 [9](转)
  8. 8.4 Change Reference to Value(将引用对象改为值对象)
  9. TypeError 之 Cannot convert undefined or null to object
  10. win11系统如何绕过tpm检测进行安装 Windows11绕过tpm安装的解决方法
  11. office增加自定义文档模板
  12. linux cat用法退出,Linux常用命令 - cat命令用法详解
  13. 【翻译】200行代码讲透RUST FUTURES (7)
  14. java求解二元二次方程_二元二次方程的解法
  15. word中无法取消图片组合
  16. 程序员情人节防止割韭菜
  17. 交互设计师谈颠覆式创新 | Think different
  18. 一份超详细的UI设计规范全攻略
  19. CSS的3d翻滚特效
  20. 天天学JAVA-JAVA基础(3)

热门文章

  1. Openstack 高可用部署(Ocata版)
  2. 人工智能对人类的机遇与挑战
  3. 笔记本计算机的连接无线网络连接,笔记本电脑怎么连无线_笔记本电脑连wifi怎么连-win7之家...
  4. 数据挖掘:概念与技术 第五章-数据立方体技术
  5. 浅谈数据库,数据仓库,数据中台
  6. zoho邮箱收费和免费区别_您需要了解有关适用于ios和android的新zoho vault移动应用程序的所有信息...
  7. 程序员的app软件开发经验
  8. PHP实现sha-256哈希算法
  9. html 设计好看的按钮,html 好看按钮
  10. VS Reporting Service--新建报表