一、背景
健康检测接口返回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地址文章来源:https://www.toymoban.com/news/detail-623721.html
- 测试环境:http://192.168.10.147:9200
- 开发环境:http://192.168.5.71:9200
修改es的地址未开发环境的地址, spring.elasticsearch.rest.uris文章来源地址https://www.toymoban.com/news/detail-623721.html
三、检验
- consul上的服务状态变成了健康,服务可用。
- 服务本身的健康检测返回:{“status”:“UP”}
到了这里,关于spring boot 服务健康检测返回OUT_OF_SERVICE,导致服务无法成功注册到consul的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!