欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

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

时间:2021-04-29 10:55:35|栏目:JAVA代码|点击:

测试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><h1>Whitelabel Error Page</h1><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 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这个端点不能使用,加上这个包,问题就解决了。

上一篇:解决HttpPost+json请求---服务器中文乱码及其他问题

栏    目:JAVA代码

下一篇:spring boot设置过滤器、监听器及拦截器的方法

本文标题:spring cloud consul注册的服务报错critical的解决

本文地址:http://www.codeinn.net/misctech/110942.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有