以前为了在一台机器上启动多个executor都是通过instance多个worker来实现的,因为standalone模式默认在一台worker上启动一个executor,造成了很大的不便利,并且会造成不同节点间任务负载不均衡,后来发现了另一种解决方法,方法如下。

设置参数

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

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。

也可以在提交任务的时候添加

--total-executor-cores 12 --executor-cores 24 --executor-memory 12g

tip

在使用过程中发现如果使用spark1.5以下版本有时候会出现即使有资源也申请不到的情况。

相关文章:

  • 2021-11-15
  • 2021-12-23
  • 2022-01-12
  • 2021-08-31
  • 2021-06-17
  • 2021-09-27
  • 2021-11-19
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2021-12-29
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案