spring boot 服务健康检测返回OUT_OF_SERVICE,导致服务无法成功注册到consul

一、背景

健康检测接口返回OUT_OF_SERVICE

curl -X GET http://192.168.5.53:8085/mgm/health

{"status":"OUT_OF_SERVICE"}

从日志启动看,没有任何报错信息;而且jvm进程也启动成功。

关键的一点信息是,服务的swagger地址访问也正常。

但是,consul上的服务状态就是不健康。
在这里插入图片描述

当然,重启大法不好使。

二、解决办法

增加配置项: management.endpoint.health.show-details: always

{
    "status":"OUT_OF_SERVICE",
    "components":{
        "consul":{
            "status":"UP",
            "details":{
                "leader":"192.168.5.65:8500",
                "services":{
                    "product-service":[
                        "secure=false"
                    ],
                    "user-service":[
                        "version=1.5.3",
                        "secure=false",
                        "management.context-path=/mgm",
                        "health.path=/health"
                    ]
                }
            }
        },
        "discoveryComposite":{
            "status":"UP",
            "components":{
                "discoveryClient":{
                    "status":"UP",
                    "details":{
                        "services":[
                            "product-service",
                            "user-service"
                        ]
                    }
                }
            }
        },
        "diskSpace":{
            "status":"UP",
            "details":{
                "total":105033031680,
                "free":68411322368,
                "threshold":10485760
            }
        },
        "elasticsearchRest":{
            "status":"OUT_OF_SERVICE",
            "details":{
                "cluster_name":"test-cluster",
                "status":"red",
                "timed_out":false,
                "number_of_nodes":1,
                "number_of_data_nodes":1,
                "active_primary_shards":93,
                "active_shards":93,
                "relocating_shards":0,
                "initializing_shards":0,
                "unassigned_shards":16,
                "delayed_unassigned_shards":0,
                "number_of_pending_tasks":0,
                "number_of_in_flight_fetch":0,
                "task_max_waiting_in_queue_millis":0,
                "active_shards_percent_as_number":85.3211009174312
            }
        },
        "hystrix":{
            "status":"UP"
        },
        "mongo":{
            "status":"UP",
            "details":{
                "version":"4.0.27"
            }
        },
        "nacosConfig":{
            "status":"UP"
        },
        "ping":{
            "status":"UP"
        },
        "rabbit":{
            "status":"UP",
            "components":{
                "globalRabbitTemplate":{
                    "status":"UP",
                    "details":{
                        "version":"3.6.6"
                    }
                },
                "rabbitTemplate":{
                    "status":"UP",
                    "details":{
                        "version":"3.6.6"
                    }
                }
            }
        },
        "redis":{
            "status":"UP",
            "details":{
                "version":"3.2.11"
            }
        },
        "refreshScope":{
            "status":"UP"
        }
    }
}
  • 可以看出,elasticsearchRest的状态是OUT_OF_SERVICE。

  • 经排查,原来是配置项误写成了测试环境的es地址

    • 测试环境:http://192.168.10.147:9200
    • 开发环境:http://192.168.5.71:9200

修改es的地址未开发环境的地址, spring.elasticsearch.rest.uris

三、检验

  • consul上的服务状态变成了健康,服务可用。
    在这里插入图片描述
  • 服务本身的健康检测返回:{“status”:“UP”}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天草二十六_简村人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值