【问题标题】:docker-compose v3 + apache spark, connection refused on port 7077docker-compose v3 + apache spark,端口 7077 上的连接被拒绝
【发布时间】:2017-03-03 06:59:17
【问题描述】:

我不确定这是 100% 编程还是系统管理员相关的问题。

我正在尝试在版本 3 中为 docker-swarm 设置一个 docker-compose 文件,docker 版本 1.13 来测试我本地工作流程的 spark。

遗憾的是,端口 7077 仅绑定到我的 swarm 集群上的本地主机,因此无法从外部世界访问,我的 spark 应用程序正在尝试连接到它。

有谁知道,如何让 docker-compose 在 swarm 模式下绑定到所有接口?

我发布了我的端口,这适用于 8080,但不适用于 7070。

nmap 输出:

Starting Nmap 7.01 ( https://nmap.org ) at 2017-03-02 11:27 PST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000096s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 994 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
443/tcp  open  https
8080/tcp open  http-proxy
8081/tcp open  blackice-icecap
8888/tcp open  sun-answerbook

端口说明

8081 is my spark worker
8080 is my spark master frontend
8888 is the spark hue frontend

nmap 未列出 7077

使用网络统计:

tcp        0      0 0.0.0.0:22              0.0.0.0:*                   LISTEN      1641/sshd       
tcp6       0      0 :::4040                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::2377                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::7946                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::80                   :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::8080                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::8081                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::6066                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::22                   :::*                    LISTEN      1641/sshd       
tcp6       0      0 :::8888                 :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::443                  :::*                    LISTEN      1634/dockerd    
tcp6       0      0 :::7077                 :::*                    LISTEN      1634/dockerd  

我可以在 localhost 上通过 telnet 连接到 7077,没有任何问题,但在 localhost 之外我收到连接被拒绝的错误。

此时(请耐心等待,我不是系统管理员,我是软件专家),我开始觉得这与 docker Mesh 网络有某种关系。

我的主配置的 Docker compose 部分:

#the spark master, having to run on the frontend of the cluster
 master:
  image: eros.fiehnlab.ucdavis.edu/spark
  command: bin/spark-class org.apache.spark.deploy.master.Master -h master
  hostname: master
  environment:
    MASTER: spark://master:7077
    SPARK_CONF_DIR: /conf
    SPARK_PUBLIC_DNS: blonde.fiehnlab.ucdavis.edu
  ports:
    - 4040:4040
    - 6066:6066
    - 8080:8080
    - 7077:7077
  volumes:
    - /tmp:/tmp/data
  networks:
    - spark
    - frontends
  deploy:
    placement:
      #only run on manager node
      constraints:
        - node.role == manager

网络 spark 和 frontend 都是覆盖网络

【问题讨论】:

  • >我可以在 localhost 上通过 telnet 连接到 7077,没有任何问题,但在 localhost 之外,我收到连接被拒绝错误。 --- 应用是否绑定到 127.0.0.1:7077?尝试将其更改为绑定到 0.0.0.0:7077
  • 任何建议如何在 docker-compose 文件中执行此操作?这真的只是 docker swarm 的一个问题,没有 docker swarm 也可以正常工作
  • 是的,您应该能够将其设置为环境变量:spark.apache.org/docs/latest/configuration.html 查找 SPARK_LOCAL_IP(或 spark.driver.bindAddress,如果您更愿意更改属性),无论如何这只是一个猜猜,不幸的是不说会解决问题:(
  • 感谢您的帮助,将其绑定到所有接口 (0.0.0.0) ,帮助将其绑定到容器 ip,但遗憾的是来自服务器外部的转发仍然无法正常工作
  • np,很高兴你终于找到了问题的根源!

标签: apache-spark docker docker-swarm


【解决方案1】:

问题是 docker-compose 文件中的配置错误。原始配置中的 -h master 始终绑定到本地主机接口。

即使在指定了 SPARK_LOCAL_IP 值之后

 master:
  image: eros.fiehnlab.ucdavis.edu/spark:latest
  command: bin/spark-class org.apache.spark.deploy.master.Master 
  hostname: master
  environment:
    SPARK_CONF_DIR: /conf
    SPARK_PUBLIC_DNS: blonde.fiehnlab.ucdavis.edu
    SPARK_LOCAL_IP: 0.0.0.0
  ports:
    - 4040:4040
    - 6066:6066
    - 8080:8080
    - 7077:7077
  volumes:
    - /tmp:/tmp/data
  deploy:
    placement:
      #only run on manager node
      constraints:
        - node.role == manager

【讨论】:

    猜你喜欢
    • 2021-10-12
    • 2019-07-31
    • 2016-03-08
    • 2017-08-05
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    相关资源
    最近更新 更多