Consul调用no instances或Consul页面All service checks failing

1.问题体现

Consul中Consumer调用Provider会出现No instances available for XXX

image-20230113161434014

这时打开Consul控制台页面:

image-20230113161553076

可以看到这里出现All services checks failing的问题

image-20230113161609171

这是 Consul 的心跳机制没有打开,所以健康检查总是报红

2.解决

1.pom

根据我个人测试,actuiator这个依赖不需要

本人使用的consul版本为1.14.3,不保证老版本不需要这个依赖

<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-starter-actuator</artifactId>-->
<!--        </dependency>-->

2.yml

添加如下图所示的heartbeat.enable=true的配置

image-20230113162052858

3.测试

consul控制台:

image-20230113162138821

服务调用:

80端口调用8006端口成功

image-20230113162310822

posted @ 2023-01-13 16:26  yikolemon  阅读(745)  评论(0)    收藏  举报