spark executor-cores参数并未对vcores生效的原因分析

转载来自:http://blog.csdn.net/rongyongfeikai2/article/details/53187421

https://blog.csdn.net/qq_35440040/article/details/78963722

虽然目前大多数平台内置Application在提交时,只配置了–num-executors和–executor-memory参数,但是其他APP的开发者可能会配置–executor-cores参数。

举个例子:

./spark-submit –master yarn-client –executor-cores 4 –num-executors 6  –executor-memory 10g –driver-memory 2g –class xxxApp xxJar  –jars $SPARK_HOME/lib/postgresql-9.4-1201.jdbc41.jar

即有6个executor,每个executor的cores数目为4。不过当你提交任务时,你一定会非常吃惊,因为yarn 8088上展示的vcores会是7。看起来就像是参数设置并未生效一样。

其实这是因为我们的capacity schedule使用的是DefaultResourceCalculator,那么DefaultResourceCalculator它在加载container时其实仅仅只会考虑内存而不考虑cores。所以,如果我们想让它既考虑内存也考虑cores的话,需要将$HADOOP_HOME/etc/hadoop/capacity-scheduler.xml

中的:

<property>
<name>yarn.scheduler.capacity.resource-calculator</name>
<value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
</property>

修改为:

<property>
<name>yarn.scheduler.capacity.resource-calculator</name>
<value>org.apache.hadoop.yarn.util.resource.DominantResourceCalculator</value>
</property>

请注意每个节点的配置文件都需要修改。并且重启hadoop。

这是再提交spark application,vcores use的数目就对了。

25=4*6+1

另外,如果不期望在命令中写executor-cores参数,可以在$SPARK_HOME/conf/spark-env.sh里配置:

export SPARK_EXECUTOR_CORES=4

这样默认executor-cores就为4了。

注意:以上的一切配置都是基于capacity调度器进行配置的,但是如果你使用的是fair调度器,那么无需配置该参数,fair调度器已经有该功能。

猜你喜欢

转载自blog.csdn.net/u013176920/article/details/82499620
今日推荐