前言:使用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端口