如何在Spark集群的work节点上启动多个Executor?

如何在Spark集群的work节点上启动多个Executor?ide


默认状况下,Spark集群下的worker,只会启动一个Executor只运行了一个 CoarseGrainedExecutorBackend 进程。Worker 经过持有 ExecutorRunner 对象来控制 CoarseGrainedExecutorBackend 的启停。
那么如何启动多个executor呢?经过设置参数来解决:spa

一、设置每一个executor使用的cpu数为4orm

spark.executor.cores 4

二、限制cpu使用数量,这里会启动3个executor(12/4)对象

spark.cores.max 12  

三、设置每一个executor的内存大小为8g进程

spark.executor.memory 12g

以上设置将会启动3个executor,每一个executor使用4cpu,12gRAM。 
总共占用worker资源12cpu,36gRAM。
ip

Spark1.6的源码部分为:内存

protected final String EXECUTOR_MEMORY = "--executor-memory";
protected final String TOTAL_EXECUTOR_CORES = "--total-executor-cores";
protected final String EXECUTOR_CORES = "--executor-cores";

也能够在提交任务的时候添加:资源

SparkSubmit --class com.dyq.spark.MyClass --master:spark://master:7077  --total-executor-cores 12 --executor-cores 24 --executor-memory 12g

tip

在使用过程当中发现若是使用spark1.5如下版本有时候会出现即便有资源也申请不到的状况。源码

相关文章
相关标签/搜索