温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

spring cloud consul注册的服务报critical错误怎么办

发布时间:2021-07-12 11:42:19 来源:亿速云 阅读:423 作者:小新 栏目:编程语言

这篇文章将为大家详细讲解有关spring cloud consul注册的服务报critical错误怎么办,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

测试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: <html><body><h2>Whitelabel Error Page</h2><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Fri Mar 15 11:03:30 CST 2019</div><div>There was an unexpected error (type=Not Found, status=404).</div><div>No message available</div></body></html>",
    "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 Finch2ey.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这个端点不能使用,加上这个包,问题就解决了。

关于“spring cloud consul注册的服务报critical错误怎么办”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI