alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.95k stars 8.34k forks source link

关于用docker 启动的sentinel-dashboard ,然而识别到的机器IP是容器的ip的问题 #1220

Open happytsgf opened 4 years ago

happytsgf commented 4 years ago

你们好,我用docker 启动的sentinel-dashboard ,然而识别到的机器IP是容器的ip,导致应用端连接不到sentinel。请问 docker启动可以由我们自己指定服务端ip地址 或者域名吗?

echooymxq commented 4 years ago

configured the spring.cloud.sentinel.transport.clientIp?

happytsgf commented 4 years ago

不是,这个在springboot配置文件就可以显示了,我现在看docker logs sentinel 的日志都是在提示:我本地的ip是172.20.60.171,但是在控制台显示的ip确实10.0.75.1 ,不知道怎么出现的,导致以下提示: 2020-03-02 14:54:30.548 ERROR 1 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher : Failed to fetch metric from http://10.0.75.1:8720/metric?startTime=1583160735000&endTime=1583160741000&refetch=false (ConnectionException: Connection timed out) 2020-03-02 14:54:37.588 ERROR 1 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher : Failed to fetch metric from http://10.0.75.1:8720/metric?startTime=1583160742000&endTime=1583160748000&refetch=false (ConnectionException: Connection timed out) 2020-03-02 14:54:44.628 ERROR 1 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher : Failed to fetch metric from http://10.0.75.1:8720/metric?startTime=1583160749000&endTime=1583160755000&refetch=false (ConnectionException: Connection timed out)

happytsgf commented 4 years ago

我看了docker启动sentinel的参数,java -Djava.security.egd=file:/dev/./urandom -Dserver.port=8858 -Dcsp.sentinel.api.port=8719 -Dcsp.sentinel.dashboard.server=localhost:8858 -Dproject.name=sentinel-dashboard -jar app.jar 。其中csp.sentinel.dashboard.server 我可以强制制定服务器IP(192.168.80.229)???

yufire commented 4 years ago

你谁啊??!

---原始邮件--- 发件人: "happytsgf"<notifications@github.com> 发送时间: 2020年3月2日(周一) 晚上11:12 收件人: "alibaba/spring-cloud-alibaba"<spring-cloud-alibaba@noreply.github.com>; 抄送: "Subscribed"<subscribed@noreply.github.com>; 主题: Re: [alibaba/spring-cloud-alibaba] 关于用docker 启动的sentinel-dashboard ,然而识别到的机器IP是容器的ip的问题 (#1220)

我看了docker启动sentinel的参数,java -Djava.security.egd=file:/dev/./urandom -Dserver.port=8858 -Dcsp.sentinel.api.port=8719 -Dcsp.sentinel.dashboard.server=localhost:8858 -Dproject.name=sentinel-dashboard -jar app.jar 。其中csp.sentinel.dashboard.server 我可以强制制定服务器IP(192.168.80.229)???

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

happytsgf commented 4 years ago

哈??? 开发者呀,正在验证使用呀,可以加钉钉?eihm6mh

echooymxq commented 4 years ago

@happytsgf csp.sentinel.dashboard.server 是指定控制台的地址,dashboard启动加这个配置的时候,是把自己也接入控制台的,你日志中拉取metric超时,你应用服务应该也是用docker启动的,此时在应用配置里面指定spring.cloud.sentinel.transport.clientIp下ip即可。

lcg72 commented 4 years ago

要保证应用也是docker启动的,docker之间是通过容器名寻址的,用docker-compose启动的话,指定容器名和主机名,并在配置的时候用容器名代替ip。如果是k8s的话,需要新建一个服务来暴露端口,配置的时候用服务暴露出来的ip

To ensure that the application is also started by docker, the address between dockers is addressed by the container name. When starting with docker compose, specify the container name and host name, and use the container name instead of IP when configuring. If it is k8s, you need to create a new service to expose the port. When configuring, use the IP exposed by the service

Nobodylesszb commented 4 years ago

请问解决了吗。我用本机测试也出现这个问题

zxyzxy1996 commented 3 years ago

请问有办法解决吗?

mhxy2018 commented 3 years ago

大佬们好,我应用也是用docker来部署的,sentinel控制台识别的客户端为docker网络,我通过在springboot应用中配置clientIp解决了该问题,但是如果我是多个节点想通过nacos配置中心来完成该项配置,显然有点不太合适,有啥解决方案么 spring.cloud.sentinel.transport.port=8719 spring.cloud.sentinel.transport.client-ip=192.168.1.8

kay07 commented 3 years ago

要保证应用也是docker启动的,docker之间是通过容器名寻址的,用docker-compose启动的话,指定容器名和主机名,并在配置的时候用容器名代替ip。如果是k8s的话,需要新建一个服务来暴露端口,配置的时候用服务暴露出来的ip

To ensure that the application is also started by docker, the address between dockers is addressed by the container name. When starting with docker compose, specify the container name and host name, and use the container name instead of IP when configuring. If it is k8s, you need to create a new service to expose the port. When configuring, use the IP exposed by the service @lcg72 k8s部署的时候映射是8719端口号假如是30020,sentinel会对后进来的服务8719端口号+1,即变成8720,那k8s这块还需要手动映射8720暴露端口号吗

jkhumm commented 3 years ago

请问解决了吗。我用本机测试也出现这个问题

我的也是使用控制台拉取客户端失败,需要指定下容器启动ip。我是用docker-compose ,你参考下。 version: "3" services: sentinel: container_name: my-sentinel-container image: bladex/sentinel-dashboard:1.7.1 environment:

jetwong0115 commented 2 years ago

我客户端用Docker部署的使用,Sentinel-Dashboard也是无法获取客户端的公网IP,识别到的是Docker网络的IP。请问这有什么解决方法?

tjh-git commented 1 year ago

我是局域网的,原来容器内的hosts只有docker内网ip和主机名映射,在hosts文件添加一个局域网映射就可以了,公网的就不清楚了