我使用快速启动cloudera VM(CDH 5.10.1)和Pyspark(1.6.0)以及Yarn(包含MR2)来汇总每小时的数值数据。我有1个CPU,4个内核和32个内存。
我有一个名为 aggregate.py 的文件,但直到今天我还没有使用spark-submit
提交作业,我使用pyspark
交互式shell并复制/粘贴测试它的代码。
在启动pyspark交互式shell时,我使用了:
pyspark --master yarn-client
我在网站用户界面中通过quickstart.cloudera:8088 / cluster进行了处理,可以看到Yarn创建了3个执行器和1个驱动程序,每个都有一个核心(不是很好的配置,但主要目的是为了证明概念,直到我们转移到真正的集群)
使用spark-submit提交相同的代码时:
spark-submit --verbose
--master yarn
--deploy-mode client \
--num-executors 2 \
--driver-memory 3G \
--executor-memory 6G \
--executor-cores 2 \
aggregate.py
我只有驱动程序,它也执行任务。请注意,spark.dynamicAllocation.enabled
在环境标签中设置为true,spark.dynamicAllocation.minExecutors
设置为2.
我只尝试使用spark-submit aggregate.py
,我仍然只有驱动程序作为执行程序。我无法通过spark-submit设置多个执行程序,但它可以在spark交互式shell中运行!
My Yarn配置如下:
yarn.nodemanager.resource.memory-mb
= 17 GiB
yarn.nodemanager.resource.cpu-vcores
= 4
yarn.scheduler.minimum-allocation-mb
= 3 GiB
yarn.scheduler.maximum-allocation-mb
= 16 GiB
yarn.scheduler.minimum-allocation-vcores
= 1
yarn.scheduler.maximum-allocation-vcores
= 2
如果有人能解释我的错误,那将是一个很大的帮助!
答案 0 :(得分:0)
您必须将驱动程序内存和执行程序内存设置为spark-defaults.conf。 它位于
$ SPARK_HOME / CONF /火花defaults.conf
如果有像
这样的文件火花defaults.conf.template
然后你必须将文件重命名为
火花defaults.conf
然后设置执行程序的数量,执行程序内存,执行程序内核的数量。您可以从模板文件中获取示例或查看此链接
https://spark.apache.org/docs/latest/configuration.html。
或
当我们使用pyspark它使用了默认的执行器 - 内存但是在spark-submit中你设置executor-memory = 6G。我认为你必须减少内存或删除此字段,以便它可以使用默认内存。
答案 1 :(得分:0)
现在根据你的spark-submit声明,
cores = num-executors 2 * executor-cores 2 + for_driver 1 = 5
#but in total you have 4 cores. So it is unable to give you executors(as after driver only 3 cores left)
#Check if this is the issue.