我有一组要对我的Spark作业可用的JAR,存储在HDFS上。
Spark 2.3的文档说spark.jars
是该参数:spark.jars: Comma-separated list of jars to include on the driver and executor classpaths. Globs are allowed.
但是,将spark.jars
设置为hdfs:///path/to/my/libs/*.jar
失败:驱动程序启动正常,启动了一个阶段,但随后任务死于:WARN TaskSetManager: Lost task 0.0 in stage 0.0 (TID 0, xxxx, executor 1): java.io.FileNotFoundException: File hdfs:/path/to/my/libs/*.jar does not exist.
at org.apache.hadoop.hdfs.DistributedFileSystem.listStatusInternal(DistributedFileSystem.java:901)
at org.apache.spark.util.Utils$.fetchHcfsFile(Utils.scala:724)
at org.apache.spark.util.Utils$.doFetchFile(Utils.scala:692)
at org.apache.spark.util.Utils$.fetchFile(Utils.scala:472)
at org.apache.spark.executor.Executor$$anonfun$org$apache$spark$executor$Executor$$updateDependencies$5.apply(Executor.scala:755)
...
即,它似乎在执行程序上运行时并没有扩展glob。
明确将spark.jars
设置为hdfs:///path/to/my/libs/libA.jar,hdfs:///path/to/my/libs/libB.jar
确实可以正常工作。
如文档所示,如何在spark.jars
中使用glob?
最佳答案
我正在从本地文件系统运行所有spark批处理和流应用程序。我不确定为什么需要将它们存储在hdfs中。
但是,如果您更喜欢使用本地文件系统来保存jar,则可以使用通配符,如下所示:-
export BASE_DIR="/local/file/path/where/jar/is/available"
spark-submit \
--class ${class} \
--deploy-mode cluster \
--master yarn \
...
...
...
--name ${APPLICATION_NAME} \
${BASE_DIR}/*.jar
希望这会有所帮助。
关于apache-spark - 提交Apache Spark作业时在spark.jars中使用通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50220378/