繁体   English   中英

Spark spark-submit --jars参数想要逗号列表,如何声明jar的目录?

[英]Spark spark-submit --jars arguments wants comma list, how to declare a directory of jars?

Spark文档中提交应用程序时,从1.6.0及更早版本开始 ,目前尚不清楚如何指定--jars参数,因为它显然不是冒号分隔的类路径而不是目录扩展。

文档说“捆绑jar的路径,包括你的应用程序和所有依赖项.URL必须在集群内部全局可见,例如,hdfs://路径或所有节点上都存在的file://路径。 “

问题:在$ SPARK_HOME / bin的spark-submit脚本中提交带有--jars的类路径的所有选项是什么? 任何未记录的内容可以作为文档的改进提交?

我问,因为当我测试 - 今天的时候,我们必须明确地提供每个jar的路径:

/usr/local/spark/bin/spark-submit --class jpsgcs.thold.PipeLinkageData ---jars=local:/usr/local/spark/jars/groovy-all-2.3.3.jar,local:/usr/local/spark/jars/guava-14.0.1.jar,local:/usr/local/spark/jars/jopt-simple-4.6.jar,local:/usr/local/spark/jars/jpsgcs-core-1.0.8-2.jar,local:/usr/local/spark/jars/jpsgcs-pipe-1.0.6-7.jar /usr/local/spark/jars/thold-0.0.1-1.jar

我们选择在每个worker上的/ usr / local / spark / jars中使用所有jar预填充集群,似乎如果没有提供local:/ file:/或hdfs:那么默认为file:/并且驱动程序使驱动程序运行的Web服务器上的jar可用。 我选择了本地,如上所述。

而且似乎我们不需要将主jar放在--jars参数中,我还没有测试过最后一个参数中的其他类(application-jar arg per docs,即/ usr / local / spark / jars / thold-0.0.1-1.jar)被发送给worker,或者如果我需要将application-jar放在-jars路径中以获取未在--class之后命名的类。

(并且使用--deploy-mode客户端使用Spark独立模式授予,您还必须在每个worker上放置驱动程序的副本,但您不知道哪个worker会运行驱动程序)

通过这种方式它很容易工作..而不是分别指定每个jar版本..

#!/bin/sh
# build all other dependent jars in OTHER_JARS

JARS=`find ../lib -name '*.jar'`
OTHER_JARS=""
   for eachjarinlib in $JARS ; do    
if [ "$eachjarinlib" != "APPLICATIONJARTOBEADDEDSEPERATELY.JAR" ]; then
       OTHER_JARS=$eachjarinlib,$OTHER_JARS
fi
done
echo ---final list of jars are : $OTHER_JARS
echo $CLASSPATH

spark-submit --verbose --class <yourclass>
... OTHER OPTIONS
--jars $OTHER_JARS,APPLICATIONJARTOBEADDEDSEPERATELY.JAR
  • 使用tr unix命令也可以像下面的例子一样。

    --jars $(echo /dir_of_jars/*.jar | tr ' ' ',')

使用--jars参数的一种方法(唯一的方法是)提供以逗号分隔的明确命名的jar列表。 我想出使用逗号的唯一方法是StackOverflow答案,这使我超越了文档到命令行:

spark-submit --help 

该命令的输出包含:

 --jars JARS                 Comma-separated list of local jars to include on the driver
                              and executor classpaths. 

今天当我测试--jars时,我们必须明确地提供每个jar的路径:

/usr/local/spark/bin/spark-submit --class jpsgcs.thold.PipeLinkageData ---jars=local:/usr/local/spark/jars/groovy-all-2.3.3.jar,local:/usr/local/spark/jars/guava-14.0.1.jar,local:/usr/local/spark/jars/jopt-simple-4.6.jar,local:/usr/local/spark/jars/jpsgcs-core-1.0.8-2.jar,local:/usr/local/spark/jars/jpsgcs-pipe-1.0.6-7.jar /usr/local/spark/jars/thold-0.0.1-1.jar

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM