我正在经历这个 Apache Spark documentation ,并提到:
When running Spark on YARN in
cluster
mode, environment variables need to be set using thespark.yarn.appMasterEnv.[EnvironmentVariableName]
property in yourconf/spark-defaults.conf
file.
我在 AWS 数据管道上运行我的 EMR 集群。我想知道我必须在哪里编辑这个 conf 文件。此外,如果我创建自己的自定义 conf 文件,并将其指定为
--configurations
的一部分(在 spark-submit 中),它会解决我的用例吗?
最佳答案
一种方法如下:(棘手的部分是您可能需要在执行程序和驱动程序参数上设置环境变量)
spark-submit \
--driver-memory 2g \
--executor-memory 4g \
--conf spark.executor.instances=4 \
--conf spark.driver.extraJavaOptions="-DENV_KEY=ENV_VALUE" \
--conf spark.executor.extraJavaOptions="-DENV_KEY=ENV_VALUE" \
--master yarn \
--deploy-mode cluster\
--class com.industry.class.name \
assembly-jar.jar
我已经在 EMR 和客户端模式下测试过它,但也应该在集群模式下工作。
关于apache-spark - 在 Spark 集群模式下设置环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47534642/