Sentinel部署報錯Failed to fetch metric 問題解決
阿新 • • 發佈:2022-03-22
前言:使用docker部署的微服務在連線sentinel一直顯示連線超時,錯誤如下
Failed to fetch metric from <http://42.192.139.**:3002/metric?startTime=1647926670000&endTime=1647926676000&refetch=false> (ConnectionException: Connection timed out)
bootstrap.yaml檔案配置sentinel,配置如下
server: port: 3001 spring: sentinel: #配置sentinel transport: dashboard:106.13.27.**:8179 #指定sentinel dashboard web 地址 clientIp: 42.192.139.** #指定和控制檯通訊的IP,若不配置,會自動選擇一個IP註冊 port: 3002 #指定sentinel元件與sentinel dashboard元件通訊地址8719
解決思路:
1、先將服務部署在雲伺服器上,比對是否docker容器對服務(3002)埠隔離了
2、開通(3002)防火牆的埠,雲服務上的(3002)埠也放開
3、發現這樣sentinel竟然能夠正常監控到,於是就在docker啟動命令上暴露連線sentinel埠,問題解決
總結:
1)bootstrap.yaml配置clientIp要指定伺服器外網Ip,不然sentinel會對服務內網Ip進行連線
2)不同服務需要切換bootstrap.yaml配置sentinel的port埠,否則會通通都預設連線伺服器的8179埠