java spring项目修改consul的健康检查地址
spring.cloud.consul.discovery.healthCheckPath
${server.servlet.context-path}/actuator/health
使用如下方式查询未正常注销的服务以及注销
list service id
curl \
http://127.0.0.1:8500/v1/agent/services
deregitration service
curl \
--request PUT \
http://127.0.0.1:8500/v1/agent/service/deregister/service_id
consul健康检查无法通过的一种情况:
首先可以通过consul的接口确认检查不能通过的详情:
curlhttp://localhost:8500/v1/agent/health/service/name/name1
consul的服务检查来自于spring actuator,actuator的检查逻辑是:
Now the health should come up. The health check basically validates predefined health check internally (Example - DataSourceHealthIndicator, DiskSpaceHealthIndicator, CassandraHealthIndicator, etc).
If one of the health indicator is down, the health will be down and you can see the error as a response after adding the property mentioned above to application.properties.
如果有一个检查不通过,则返回down,所以可以看到服务正常启动,但是consul健康检查过不去的情况,需要打开
management:
endpoint:
health:
show-details: always
将health的detail打开看一下具体哪个启动项目有问题,解决以后才能通过。
网友评论