纱线执行者推出错误版火花

时间:2016-10-21 09:52:55

标签: apache-spark pyspark yarn

我有一个安装了hadoop 2.6.3和spark 1.6的集群。

最近,我把火花升级到了2.0,一切看起来都很好,直到我试图运行一些火花1.6的旧工作,这与火花2.0有一些相容的问题。

我尝试的第一件事是:

echo $SPARK_HOME
/usr/local/spark-1.6.1-bin-hadoop2.6
/usr/local/spark-1.6.1-bin-hadoop2.6/bin/spark-submit  --master yarn--deploy-mode client /usr/local/spark-1.6.1-bin-hadoop2.6/examples/src/main/python/pi.py 100

然而,上述工作失败,当我检查纱线日志时,我发现了以下内容:

YARN executor launch context:
env:
CLASSPATH -> {{PWD}}<CPS>{{PWD}}/__spark__.jar<CPS>$HADOOP_CONF_DIR<CPS>$HADOOP_COMMON_HOME/share/hadoop/common/*<CPS>$HADOOP_COMMON_HOME/share/hadoop/common/lib/*<CPS>$HADOOP_HDFS_HOME/share/hadoop/hdfs/*<CPS>$HADOOP_HDFS_HOME/share/hadoop/hdfs/lib/*<CPS>$HADOOP_YARN_HOME/share/hadoop/yarn/*<CPS>$HADOOP_YARN_HOME/share/hadoop/yarn/lib/*<CPS>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*<CPS>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*
SPARK_LOG_URL_STDERR -> http://datanode01-bi-dev:8042/node/containerlogs/container_1476081972773_0194_01_000003/hadoop/stderr?start=-4096
    SPARK_YARN_STAGING_DIR -> .sparkStaging/application_1476081972773_0194
    SPARK_YARN_CACHE_FILES_FILE_SIZES -> 187698038,357051,44846
    SPARK_USER -> hadoop
    SPARK_YARN_CACHE_FILES_VISIBILITIES -> PRIVATE,PRIVATE,PRIVATE
    SPARK_YARN_MODE -> true
    SPARK_YARN_CACHE_FILES_TIME_STAMPS -> 1477040367079,1477040367425,1477040367454
    SPARK_HOME -> /usr/local/spark-2.0.0-bin-hadoop2.6
    PYTHONPATH -> /usr/local/spark-1.6.1-bin-hadoop2.6/python/lib/py4j-0.9-src.zip:<CPS>{{PWD}}/pyspark.zip<CPS>{{PWD}}/py4j-0.9-src.zip
    SPARK_LOG_URL_STDOUT -> http://datanode01-bi-dev:8042/node/containerlogs/container_1476081972773_0194_01_000003/hadoop/stdout?start=-4096
    SPARK_YARN_CACHE_FILES -> hdfs://10.104.90.40:8020/user/hadoop/.sparkStaging/application_1476081972773_0194/spark-assembly-1.6.1-hadoop2.6.0.jar#__spark__.jar,hdfs://10.104.90.40:8020/user/hadoop/.sparkStaging/application_1476081972773_0194/pyspark.zip#pyspark.zip,hdfs://10.104.90.40:8020/user/hadoop/.sparkStaging/application_1476081972773_0194/py4j-0.9-src.zip#py4j-0.9-src.zip
  command:
  {{JAVA_HOME}}/bin/java -server -XX:OnOutOfMemoryError='kill %p' -Xms1024m -Xmx1024m -Djava.io.tmpdir={{PWD}}/tmp '-Dspark.driver.port=26087' '-Dspark.ui.port=0' -Dspark.yarn.app.container.log.dir=<LOG_DIR> -XX:MaxPermSize=256m org.apache.spark.executor.CoarseGrainedExecutorBackend --driver-url spark://CoarseGrainedScheduler@10.104.90.41:26087 --executor-id 2 --hostname datanode01-bi-dev --cores 1 --app-id application_1476081972773_0194 --user-class-path file:$PWD/__app__.jar 1> <LOG_DIR>/stdout 2> <LOG_DIR>/stderr
.......
.......
Traceback (most recent call last):
  File "pi.py", line 39, in <module>
    count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add)
  File "/usr/local/spark-2.0.0-bin-hadoop2.6/python/lib/pyspark.zip/pyspark/rdd.py", line 802, in reduce
  File "/usr/local/spark-2.0.0-bin-hadoop2.6/python/lib/pyspark.zip/pyspark/rdd.py", line 776, in collect
  File "/usr/local/spark-2.0.0-bin-hadoop2.6/python/lib/pyspark.zip/pyspark/rdd.py", line 2403, in _jrdd
  File "/usr/local/spark-2.0.0-bin-hadoop2.6/python/lib/pyspark.zip/pyspark/rdd.py", line 2338, in _wrap_function
  TypeError: 'JavaPackage' object is not callable

很明显,纱线使用Spark 2.0使执行程序陷入困境并导致失败的问题。

我检查了我能想到的每个角落都与火花环境的设置有关,我无处可寻找火花2.0。

在〜/ .bashrc中,我有:

export PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.9-src.zip:$PYTHONPATH
export SPARK_HOME=/usr/local/spark-2.0.0-bin-hadoop2.6

下面的命令给出了空结果:

grep -rnw /usr/local/spark-1.6.1-bin-hadoop2.6 -e spark-2.0.0-bin-hadoop2.6 
grep -rnw /usr/local/hadoop-2.6.3 -e spark-2.0.0-bin-hadoop2.6

我在namenode和datanode上尝试了上述场景,只是为了得到相同的结果。

但是,java Pi示例可以成功运行。

spark-submit --master yarn --deploy-mode cluster --class org.apache.spark.examples.SparkPi /usr/local/spark-1.6.1-bin-hadoop2.6/lib/spark-examples-1.6.1-hadoop2.6.0.jar 100

任何人都可以分享为什么纱线会加载错误版本的火花吗?

更新

问题实际上是由于我的PATH搞砸了。因此,在我清理路径并将spark 2.0设置为spark提交的默认版本之后。现在一切都很好。

1 个答案:

答案 0 :(得分:0)

首先评论您的.bashrc导出并将其从环境中移除 - 它们不兼容。 PYTHONPATH使用spark 1.6 libs和SPARK_HOME点来激发2.0。

然后在两个版本上使用spark-submit的绝对路径运行示例 - spark-submit根据其位置设置SPARK_HOME,因此它应该适用于两个版本。