如何更改 Spark 设置以允许 spark.dynamicAllocation.enabled?

mfl*_*www 6 python configuration dynamic-allocation apache-spark pyspark

我在 pyspark 中运行 python 脚本并收到以下错误:NameError: name 'spark' is not defined

我查了一下,发现原因是spark.dynamicAllocation.enabled目前还不允许。

根据 Spark 的文档(https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-dynamic-allocation.html#spark_dynamicAllocation_enabled):(spark.dynamicAllocation.enabled默认false:)控制是否启用动态分配。假定spark.executor.instances未设置或为 0(这是默认值)。

由于默认设置是false,我需要更改 Spark 设置以启用spark.dynamicAllocation.enabled.

我用 brew 安装了 Spark,并没有改变它的配置/设置。

如何更改设置并启用spark.dynamicAllocation.enabled

非常感谢。

Ram*_*ram 7

问题:如何更改设置并启用 spark.dynamicAllocation.enabled?

您可以通过 3 个选项来实现这一点。
1) 修改下面提到的参数spark-defaults.conf
2) 从您的 --conf 发送以下参数spark-submit
3) 以编程方式指定动态分配的配置,如下所示。

其中以编程方式你可以这样做你可以像这样以编程方式做到这一点。

val conf = new SparkConf()
      .setMaster("ClusterManager")
      .setAppName("test-executor-allocation-manager")
      .set("spark.dynamicAllocation.enabled", "true")
      .set("spark.dynamicAllocation.minExecutors", 1)
      .set("spark.dynamicAllocation.maxExecutors", 2)
      .set("spark.shuffle.service.enabled", "true") // for stand alone
Run Code Online (Sandbox Code Playgroud)


Joe*_*den 3

有几个地方可以设置它。如果您想在每个作业的基础上启用它,请在每个应用程序中设置以下内容:

conf.set("spark.dynamicAllocation.enabled","true")
Run Code Online (Sandbox Code Playgroud)

如果要为所有作业设置 if,请导航至spark.conf 文件。在 Hortonworks 发行版中应该是

/usr/hdp/current/spark-client/conf/
Run Code Online (Sandbox Code Playgroud)

将设置添加到您的spark-defaults.conf 中,应该就可以了。