栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

spring cloud consul注册的服务报错critical的解决

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring cloud consul注册的服务报错critical的解决

测试spring cloud 使用consul注册服务的时候,出现critical,如下:

怎么解决这个问题,现在只能看到health check检查失败了。

受限调用这个请求Get http://consulIp:8500/v1/agent/checks,调完请求,就会拿到返回数据:

{
  ......
  "service:test-service-xx-xx-xx-xx": {
    "Node": "zookeeper-server1",
    "CheckID": "service:test-service-xx-xx-xx-xx",
    "Name": "Service 'test-service' check",
    "Status": "critical",
    "Notes": "",
    "Output": "HTTP GET http://xxx.xx.xxx.xxx:19008/actuator/health: 404 Output: Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Mar 15 11:03:30 CST 2019There was an unexpected error (type=Not Found, status=404).No message available", "ServiceID": "test-service-xx-xx-xx-xx", "ServiceName": "test-service", "ServiceTags": [ "version=1.0", "secure=false" ], "Definition": {}, "CreateIndex": 0, "ModifyIndex": 0 } ........ }

就能看到consul调用http://xxx.xx.xxx.xxx:19008/actuator/health来检查servoce健康,却发现接口404,所以才会在页面出现错误。

我的测试环境是:

  • spring cloud Finch1ey.SR2
  • consul v1.4.3

bootstrap.yml配置是:

spring:
 cloud:
  consul:
   host: xxx.xxx.xxx.xxx
   port: 8500
   discovery:
    prefer-ip-address: true
    tags: version=1.0
    instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}
    healthCheckInterval: 15s
    health-check-url: http://${spring.cloud.client.ip-address}:${server.port}/actuator/health

显然consul不能在这个服务上找到actuator/health接口,因为我用了actuator,所以service中应该配置了spring cloud actuator。

经过检查发现没有配置,所以actuator这个端点不能使用,加上这个包,问题就解决了。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/138721.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号