測(cè)試spring cloud 使用consul注冊(cè)服務(wù)的時(shí)候,出現(xiàn)critical,如下:
怎么解決這個(gè)問(wèn)題,現(xiàn)在只能看到health check檢查失敗了。
受限調(diào)用這個(gè)請(qǐng)求Get http://consulIp:8500/v1/agent/checks,調(diào)完請(qǐng)求,就會(huì)拿到返回?cái)?shù)據(jù):
{ ...... "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調(diào)用http://xxx.xx.xxx.xxx:19008/actuator/health來(lái)檢查servoce健康,卻發(fā)現(xiàn)接口404,所以才會(huì)在頁(yè)面出現(xiàn)錯(cuò)誤。
我的測(cè)試環(huán)境是:
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不能在這個(gè)服務(wù)上找到actuator/health接口,因?yàn)槲矣昧薬ctuator,所以service中應(yīng)該配置了spring cloud actuator。
經(jīng)過(guò)檢查發(fā)現(xiàn)沒(méi)有配置,所以actuator這個(gè)端點(diǎn)不能使用,加上這個(gè)包,問(wèn)題就解決了。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VeVb武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選