我在客户端模式下在YARN上运行Spark,所以我希望YARN只为执行者分配容器 . 然而,从我所看到的情况来看,似乎还为驱动程序分配了一个容器,而且我没有像我期望的那样获得尽可能多的执行程序 .
我在主节点上运行spark submit . 参数如下:
sudo spark-submit --class ... \
--conf spark.master=yarn \
--conf spark.submit.deployMode=client \
--conf spark.yarn.am.cores=2 \
--conf spark.yarn.am.memory=8G \
--conf spark.executor.instances=5 \
--conf spark.executor.cores=3 \
--conf spark.executor.memory=10G \
--conf spark.dynamicAllocation.enabled=false \
在运行此应用程序时,Spark UI的Executors页面显示1个驱动程序和4个执行程序(总共5个条目) . 我希望有5个,而不是4个执行者 . 同时,YARN UI的Nodes选项卡显示在未实际使用的节点上(至少根据Spark UI的Executors页面...),使用9GB内存分配了一个容器 . 其余节点上都有容器,每个节点有11GB内存 .
因为在我的Spark提交中,驱动程序的内存比执行程序少2GB,我认为YARN分配的9GB容器是针对驱动程序的 .
Why is this extra container allocated? How can i prevent this?
Spark UI:
YARN UI:
由Igor Dvorzhak回答后更新
我错误地假设AM将在主节点上运行,并且它将包含驱动程序应用程序(因此设置spark.yarn.am . *设置将与驱动程序进程相关) .
所以我做了以下更改:
-
将
spark.yarn.am.*
设置为默认值(512m内存,1个内核) -
将驱动程序内存通过
spark.driver.memory
设置为8g -
根本没有尝试设置驱动程序核心,因为它仅对集群模式有效
由于AM在默认设置下占用512m 384m的开销,因此其容器适合工作节点上的备用1GB可用内存 . Spark获取它请求的5个执行程序,驱动程序内存适合8g设置 . 一切都按预期工作了 .
Spark UI:
YARN UI:
2 回答
额外容器分配给YARN application master:
即使客户端模式驱动程序在客户端进程中运行,YARN应用程序主服务器仍在YARN上运行并需要容器分配 .
无法阻止YARN应用程序主机的容器分配 .
作为参考,时间问题类似的问题:Resource Allocation with Spark and Yarn .
您可以在spark提交中指定驱动程序内存和执行程序数,如下所示 .
spark-submit --jars ..... - master yarn --deploy-mode cluster --driver-memory 2g --driver-cores 4 --num-executors 5 --executor-memory 10G --executor-cores 3
希望它能帮到你 .