spring cloud consul注冊(cè)的服務(wù)報(bào)錯(cuò)critical的解決
測(cè)試spring cloud 使用consul注冊(cè)服務(wù)的時(shí)候,出現(xiàn)critical,如下:
怎么解決這個(gè)問題,現(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來檢查servoce健康,卻發(fā)現(xiàn)接口404,所以才會(huì)在頁面出現(xiàn)錯(cuò)誤。
我的測(cè)試環(huán)境是:
- 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不能在這個(gè)服務(wù)上找到actuator/health接口,因?yàn)槲矣昧薬ctuator,所以service中應(yīng)該配置了spring cloud actuator。
經(jīng)過檢查發(fā)現(xiàn)沒有配置,所以actuator這個(gè)端點(diǎn)不能使用,加上這個(gè)包,問題就解決了。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
java 內(nèi)部類(匿名類,匿名對(duì)象,靜態(tài)內(nèi)部類)詳解及實(shí)例
這篇文章主要介紹了java 內(nèi)部類詳解及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2016-12-12Java設(shè)計(jì)模式編程之解釋器模式的簡(jiǎn)單講解
這篇文章主要介紹了Java設(shè)計(jì)模式編程之解釋器模式的講解,解釋器設(shè)計(jì)模式要注意其引發(fā)的性能問題,需要的朋友可以參考下2016-04-04Java如何使用流去除集合中某個(gè)字段為空的對(duì)象
這篇文章主要給大家介紹了關(guān)于Java如何使用流去除集合中某個(gè)字段為空的對(duì)象,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Java具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-08-08SpringMVC數(shù)據(jù)輸出相關(guān)知識(shí)總結(jié)
今天帶大家學(xué)習(xí)SpringMVC的相關(guān)知識(shí),文中對(duì)SpringMVC數(shù)據(jù)輸出作了非常詳細(xì)的代碼示例,對(duì)正在學(xué)習(xí)的小伙伴們很有幫助,需要的朋友可以參考下2021-06-06