在 spark-submit 命令中,我们如何同时使用 spark-defaults.conf 文件和文件中定义的一些 spark 属性?

问题描述

背景: 在我的 Scala/Spark 项目中,我使用了一个 oozie worflow,它会启动一个 spark-submit 命令。

<workflow-app xmlns='uri:oozie:workflow:0.4' name='workflow_name'>
    ...
    <action name='action1'>
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>jobTracker</job-tracker>
            <name-node>namenode</name-node>
            <job-xml>blabla</job-xml>
            <exec>spark-submit</exec>
            <argument>--verbose</argument>
            <argument>--master</argument>
            <argument>yarn</argument>
            <argument>--deploy-mode</argument>
            <argument>cluster</argument>
            <argument>--name</argument>
            <argument>ApplicationName</argument>
            <argument>--class</argument>
            <argument>classpath</argument>
            <argument>assembly.jar</argument>

            <file>assemblyPath/assembly.jar</file>
        </shell>
            ...
</workflow-app>

我想使用 sparkConfFile.conf 中定义的一些 spark 属性来执行此 spark-submit 命令,例如:

spark.executor.memoryOverhead=2458
spark.executor.instances=5
spark.executor.memory=8G
spark.executor.cores=2
spark.driver.memory=3G

我的尝试:

  1. 使用 --properties-file 参数
<exec>spark-submit</exec>
<argument>--verbose</argument>
<argument>--master</argument>
<argument>yarn</argument>
<argument>--deploy-mode</argument>
<argument>cluster</argument>
<argument>--name</argument>
<argument>ApplicationName</argument>
<argument>--class</argument>
<argument>classpath</argument>

<argument>--files</argument>
<argument>filePath/sparkConfFile.conf</argument>
<argument>--properties-file</argument>
<argument>sparkConfFile.conf</argument>

<argument>assembly.jar</argument>

<file>assemblyPath/assembly.jar</file>
<file>filePath/sparkConfFile.conf</argument>

它与我的火花调谐正常工作。但是这样做,它使我能够仅使用 sparkConfFile.conf 文件中定义的 spark 属性启动我的应用程序,而不会考虑 spark-defaults.conf 文件。 它不会覆盖 spark-defaults.conf 的变量。

如何使用这两个文件支持文件中定义的 spark 属性

我看到当我定义 2 个属性文件时,它使用了最后一个如何使用多个属性文件?那么文件的顺序呢?

  1. 使用解析器

通过解析这个文件来创建 applicationConfig。因此,可以使用参数中给出的 applicationConfig 创建 sparkContext。 通过这种方式,我的应用程序使用 spark-defaults.conf 文件的 spark 属性和 sparkConfFile.conf 的一些 spark 属性执行。 不考虑 spark 驱动程序属性和 spark.executor.instances。

  1. 使用 --conf

http://florentfo.rest/2019/01/07/configuring-spark-applications-with-typesafe-config.html#yarn-cluster-mode

<exec>spark-submit</exec>
<argument>--verbose</argument>
<argument>--master</argument>
<argument>yarn</argument>
<argument>--deploy-mode</argument>
<argument>cluster</argument>
<argument>--name</argument>
<argument>ApplicationName</argument>
<argument>--class</argument>
<argument>classpath</argument>

<argument>--files</argument>
<argument>filePath/sparkConfFile.conf</argument>
<argument>--conf</argument>
<argument>spark.driver.extrajavaoptions=-Dconfig.file=sparkConfFile.conf</argument>
<argument>--conf</argument>
<argument>spark.executor.extrajavaoptions=-Dconfig.file=sparkConfFile.conf</argument>

<argument>assembly.jar</argument>


<file>assemblyPath/assembly.jar</file>
<file>filePath/sparkConfFile.conf</argument>

它启动了使用 spark-defaults.conf 而不是我的 sparkConfFile.conf 的应用程序......

尝试了所有这些想法后,它仍然不起作用。 欢迎您提出意见、问题和建议!

提前致谢! :)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...