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

pdsfdshx  于 2021-07-14  发布在  Spark
关注(0)|答案(0)|浏览(249)

上下文:在我的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

我尝试的是:
使用--properties文件参数

<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>

它与我的Spark调整正常工作。但是这样做,它使我能够仅使用sparkconffile.conf文件中定义的spark属性启动应用程序,而不考虑spark-defaults.conf文件。它不会覆盖spark-defaults.conf的变量。
如何使用这两个文件并支持文件中定义的spark属性?
我看到当我定义了两个属性文件时,它使用了最后一个。如何使用多个属性文件?档案的顺序呢?
使用解析器
通过分析此文件创建applicationconfig。因此,可以使用参数中给定的applicationconfig创建sparkcontext。这样,我的应用程序将使用spark-defaults.conf文件的spark default属性和sparkconffile.conf的一些spark属性执行。不考虑spark驱动程序属性和spark.executor.instances。
使用--conf
http://florentfo.rest/2019/01/07/configuring-spark-applications-with-typesafe-config.html#yarn-群集模式

<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的应用程序。。。
在尝试了所有这些想法之后,它仍然不起作用。欢迎您的意见、问题和建议!
提前谢谢!:)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题