Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在docker中启动工作节点并连接到主机操作系统上运行的主节点_Docker_Apache Spark_Apache Spark 2.0 - Fatal编程技术网

在docker中启动工作节点并连接到主机操作系统上运行的主节点

在docker中启动工作节点并连接到主机操作系统上运行的主节点,docker,apache-spark,apache-spark-2.0,Docker,Apache Spark,Apache Spark 2.0,我正在试验在独立模式下运行spark。主节点和工作节点已启动并在主机操作系统上运行 我正在尝试启动一个docker容器作为工作节点运行。主机操作系统是ubuntu 18.04 64位。 容器Dockerfile如下所示,它将运行alpine linux ### Dockerfile for creating images of spark worker #set the base image as alpine-java # headless openjdk8. FROM anapsix

我正在试验在独立模式下运行spark。主节点和工作节点已启动并在主机操作系统上运行

我正在尝试启动一个docker容器作为工作节点运行。主机操作系统是ubuntu 18.04 64位。 容器Dockerfile如下所示,它将运行alpine linux

### Dockerfile for creating images of spark worker


#set the base image as alpine-java 
# headless openjdk8.
FROM anapsix/alpine-java

#install few required dependencies in the alpine linux os
#To upgrade all the packages of a running system, use upgrade
#install wget to download the hadoop,spark binaries
#install git  as all the required softwares for  alpine are in git repos
#install unzip to unzip the downloaded  files
#Py4J enables Python programs running in a Python interpreter
#to dynamically access java objects in a JVM.
RUN apk update --no-cache && apk upgrade --no-cache && \
    apk add --no-cache wget \
            git \
            unzip \
            python3 \
            python3-dev && \
            pip3 install --no-cache-dir --upgrade pip -U py4j && \
            cd /home && \
            wget http://www-eu.apache.org/dist/spark/spark-2.3.1/spark-2.3.1-bin-hadoop2.7.tgz && \
            tar -xvf spark-2.3.1-bin-hadoop2.7.tgz && \
            rm -rf spark-2.3.1-bin-hadoop2.7.tgz && \
            rm -rf /var/cache/* && \
            rm -rf /root/.cache/*

# set some enviroment variables for the alpine

# setting the seed value of hash randomization to an integer
ENV PYTHONHASHSEED 2

ENV SPARK_HOME /home/spark-2.3.1-bin-hadoop2.7
ENV PYSPARK_PYTHON python3
ENV PATH $PATH:$SPARK_HOME/bin
WORKDIR $SPARK_HOME
ENTRYPOINT $SPARK_HOME/bin/spark-class org.apache.spark.deploy.worker.Worker $MYMASTER
使用以下命令使用上面的Dockerfile创建图像

docker build -t spkworker .
已成功创建映像

问题在于使用以下命令启动工作节点时 Dockerfile有一个变量
$MYMASTER
,该变量应该传递主URL以部署工作程序

run命令如下:我在env变量中传递主节点URL

docker run spkworker --name worker1 --env MYMASTER=spark://127.0.1.1:7077
它失败,错误为msg

2018-08-05 18:00:57 INFO  Worker:2611 - Started daemon with process name: 8@44bb0d682a48
2018-08-05 18:00:57 INFO  SignalUtils:54 - Registered signal handler for TERM
2018-08-05 18:00:57 INFO  SignalUtils:54 - Registered signal handler for HUP
2018-08-05 18:00:57 INFO  SignalUtils:54 - Registered signal handler for INT
Usage: Worker [options] <master>

Master must be a URL of the form spark://hostname:port

Options:
  -c CORES, --cores CORES  Number of cores to use
  -m MEM, --memory MEM     Amount of memory to use (e.g. 1000M, 2G)
  -d DIR, --work-dir DIR   Directory to run apps in (default: SPARK_HOME/work)
  -i HOST, --ip IP         Hostname to listen on (deprecated, please use --host or -h)
  -h HOST, --host HOST     Hostname to listen on
  -p PORT, --port PORT     Port to listen on (default: random)
  --webui-port PORT        Port for web UI (default: 8081)
  --properties-file FILE   Path to a custom Spark properties file.
                           Default is conf/spark-defaults.conf.
2018-08-05 18:00:57信息工作者:2611-已启动进程名为的守护程序:8@44bb0d682a48
2018-08-05 18:00:57信息信号处理程序:54-注册信号处理程序
2018-08-05 18:00:57信息信号处理程序:54-HUP注册信号处理程序
2018-08-05 18:00:57信息信号处理程序:54-注册的INT信号处理程序
用法:Worker[选项]
Master必须是表单的URLspark://hostname:port
选项:
-c芯,--要使用的芯数
-m MEM,--内存MEM要使用的内存量(例如1000M、2G)
-d DIR,--运行应用程序的工作目录(默认:SPARK_HOME/work)
-要侦听的i主机,-ip主机名(已弃用,请使用--HOST或-h)
-h主机,--要侦听的主机主机名
-p端口,--要侦听的端口(默认值:随机)
--web UI的webui端口(默认值:8081)
--属性文件自定义Spark属性文件的路径。
默认值为conf/spark-defaults.conf。

如何传递主节点详细信息以启动工作节点

工作节点和主节点位于不同的网络中。 一种可能的解决方案是向容器(工作节点)指示必须使用其主机的网络

docker run --net=host --name worker1 --env MYMASTER=spark://$HOSTNAME:7077 spkworker

工作节点和主节点位于不同的网络中。 一种可能的解决方案是向容器(工作节点)指示必须使用其主机的网络

docker run --net=host --name worker1 --env MYMASTER=spark://$HOSTNAME:7077 spkworker

感谢您的建议,将辅助服务器和主服务器连接到同一网络,即主机解决了问题。我使用下面一行代码来启动工作节点<代码>docker运行--环境MYMASTER=spark://127.0.1.1:7077 --网络主机--名称worker4-itd spkworker感谢您建议将工作机和主机连接到同一网络,即主机解决了此问题。我使用下面一行代码来启动工作节点<代码>docker运行--环境MYMASTER=spark://127.0.1.1:7077 --网络主机--名称worker4-itd spkworker