【问题标题】:Reading App.conf and Log4j.properties from Spark submit command从 Spark submit 命令读取 App.conf 和 Log4j.properties
【发布时间】:2021-12-11 16:58:00
【问题描述】:

我正在尝试传递我的 jar 中的 application.conf 和 Log4j.properties,但我想从外部传递它们。我通过 spark submit 命令试了一下,如下:

/opt/apps/spark/bin/spark-submit 
    --files /opt/apps/spark/code/src/main/resources/application.conf 
    --conf spark.driver.extraJavaOptions=-Dconfig.file=/opt/apps/spark/code/src/main/resources/application.conf 
    --conf spark.executor.extraJavaOptions=-Dconfig.file=/opt/apps/spark/code/src/main/resources/application.conf 
    --driver-java-options Dlog4j.configuration=File:///opt/apps/spark/code/src/main/resources/Log4j.properties 
    --class com.ericsson.dnb.main.staging.SnifferReportStatus /opt/apps/spark/code/target/scala-2.12/dnb-reporting-1A-4.0.0.ft.jar

它不会抛出任何错误,但它只是从指定的路径读取 log4j.properties 并从 JAR 本身获取 application.conf。有什么方法可以通过 Spark submit 命令在 JAR 之外提供这两个配置?

【问题讨论】:

    标签: scala apache-spark hadoop log4j spark-submit


    【解决方案1】:

    我认为这是因为您忘记将 file:// 附加到您的应用程序配置文件中,而您对 log4j.properties 文件执行了相同操作。

    下面的代码应该可以工作

    /opt/apps/spark/bin/spark-submit --files File:///opt/apps/spark/code/src/main/resources/application.conf --conf spark.driver.extraJavaOptions=-Dconfig.file=File:///opt/apps/spark/code/src/main/resources/application.conf --conf spark.executor.extraJavaOptions=-Dconfig.file=File:///opt/apps/spark/code/src/main/resources/application.conf --driver-java-options -Dlog4j.configuration=File:///opt/apps/spark/code/src/main/resources/Log4j.properties --class com.ericsson.dnb.main.staging.SnifferReportStatus /opt/apps/spark/code/target/scala-2.12/dnb-reporting-1A-4.0.0.ft.jar
    

    【讨论】:

    • 嗨 Vikas,我在线程“main”java.io.IOException 中收到以下错误异常:方案没有文件系统:org.apache.hadoop.fs.FileSystem.getFileSystemClass 中的文件(FileSystem.java :2660) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667) 我不这么认为是因为没有添加 File:// 因为在日志中我可以看到 application.conf 正在获取存储在 spark 的本地 HDFS 中。我认为问题在于,通过添加 --driver-java-options ,它会覆盖先前加载的 applicationg.conf 并忽略它并从 JAR 中获取它。
    • 需要解决这个问题。这样两个配置都是从提交命令本身而不是从 JAR 加载的。任何帮助将不胜感激。
    猜你喜欢
    • 2017-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多