问题描述
背景: 在我的 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-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 的变量。
我看到当我定义 2 个属性文件时,它使用了最后一个。 如何使用多个属性文件?那么文件的顺序呢?
- 使用解析器
通过解析这个文件来创建 applicationConfig。因此,可以使用参数中给出的 applicationConfig 创建 sparkContext。 通过这种方式,我的应用程序使用 spark-defaults.conf 文件的 spark 默认属性和 sparkConfFile.conf 的一些 spark 属性执行。 不考虑 spark 驱动程序属性和 spark.executor.instances。
- 使用 --conf
<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 (将#修改为@)