Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

[BUG] 容器ip和宿主机ip怎么指定

Open zhengduoru opened this issue 1 year ago • 1 comments

我在一个容器中启动了 client,该容器的ip是172.18.0.xxx,容器对应的宿主机ip是 10.148.18.xxx。以下的问题就是关于这两个ip的。

我启动client的命令是java -Dcsp.sentinel.dashboard.server=10.37.135.xxx:8080 -Dproject.name=appA -Dserver.port=7001 -Dspring.application.name=cluster-client-1 -Dcsp.sentinel.heartbeat.client.ip=10.148.18.xxx -jar target/sentinel-cluster-client-1-1.0.0-SNAPSHOT.jar 这里我专门加了一个-Dcsp.sentinel.heartbeat.client.ip参数,把ip指向我的容器对应的宿主机(因为我开了dashboard的机器只能ping到宿主机的ip,ping不通容器的ip)。

但是我发现这个client起来之后,我在开dashboard机器的日志里看到了Failed to fetch metric from http://10.148.18.xxx:8719/metric?startTime=1708088169000&endTime=1708088175000&refetch=false (ConnectionException: Connection refused)

看到这个报错,我就去client的容器里,curl了一下,curl http://10.148.18.xxx:8719/metric?startTime=1708088169000&endTime=1708088175000&refetch=false,显示 Failed to connect to 10.148.18.xxx port 8719: Connection refused

但是 curl了一下,curl http://172.18.0.xxx:8719/metric?startTime=1708088169000&endTime=1708088175000&refetch=false,就显示了正常的日志1708088365000|system_load|499200|0|0|0|0|0|0|0 1708088365000|cpu_usage|1563|0|0|0|0|0|0|0

说明这个client起来之后,向dashboard发送日志的服务还是用 172.18.0.xxx 这个ip起来的,不是用我指定的-Dcsp.sentinel.heartbeat.client.ip=10.148.18.xxx起来的,想问下这个问题应该怎么解呀?

zhengduoru avatar Feb 16 '24 13:02 zhengduoru

看一下HeartbeatSender具体使用的哪一个。SpringMvcHttpHeartbeatSender和HttpHeartbeatSender应该都是可以的

sirius19 avatar Mar 07 '24 09:03 sirius19