阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Spark资源调度和配置说明

204次阅读
没有评论

共计 3108 个字符,预计需要花费 8 分钟才能阅读完成。

Spark 资源调度有两类(这里主要介绍的是 yarn 为 master 的调度)

1、master 管理的调度

当你在 Hadoop 集群上运行你的 spark 应用程序的时候,每个应用程序都将申请获取相应的一组独立的用以运行该 taske 的 JVM 资源资源,默认情况下,使用的调度方式是一组静态的也是最简单的方式,它允许每个应用程序获取它所需要的最大限制的资源,并且直到运行结束前,一直拥有他们。

yarn 可以使用 –num-executors 和—executor-memory 以及—executor-core 来分配 spark 应用程序所需要的 executors 和每个 executor 所能使用的 memory、core 资源

yarn 也提供一种动态的资源管理来分配应用程序需要的资源。也就是应用程序根据你的应用来适当增加或减少你所使用的资源。并且这样特性目前只 yarn 才支持

配置安装:

所有可用的属性使用 spark.dynamicAllocation.* 配置

启用动态资源管理选项:spark.dynamicAllocation.enabled

配置 executers 动态分配使用 spark.dynamicAllocation.minExecutors

和 spark.dynamicAllocation.maxExecutors

设置 spark.shuffle.service.enabled 为 true 启用 shuffle service(yarn 的由 org.apache.spark.yarn.network.YarnShuffleService 实现

如果使用动态的资源管理,那额外的还需要启动一个 shuffle 服务一确保被 executor 所读写的 shuffle 文件在 executor 退出后被保存

启用方法:set spark.shuffle.service.enabled to true

在 yarn 中启用 shuffle service 的步骤:

Build Spark with the YARN profile. Skip this step if you are using a pre-packaged distribution.
Locate the spark-<version>-yarn-shuffle.jar. This should be under $SPARK_HOME/network/yarn/target/scala-<version> if you are building Spark yourself, and under lib if you are using a distribution.
Add this jar to the classpath of all NodeManagers in your cluster.
In the yarn-site.xml on each node, add spark_shuffle to yarn.nodemanager.aux-services, then set yarn.nodemanager.aux-services.spark_shuffle.class to org.apache.spark.network.yarn.YarnShuffleService. Additionally, set all relevantspark.shuffle.service.* configurations.
Restart all NodeManagers in your cluster.
动态资源管理策略相关的参数:

spark.dynamicAllocation.schedulerBacklogTimeout

spark.dynamicAllocation.sustainedSchedulerBacklogTimeout

2、spark 应用程序管理的调度

在一个 executor 中根据任务的不同将会并行的运行的不同 jobs,它们之间也存在资源竞争,并且 spark 的调度室线程安全的和支持应用程序服务多用户请求(例如多用户查询)默认情况下 spark 使用的是 FIFO 的方式调度,spark 也支持 FAIR 调度

设置方式:

conf = new SparkConf().setMaster(…).setAppName(…) 
conf.set(“spark.scheduler.mode”, “FAIR”) 
sc = new SparkContext(conf)
默认情况下,使用公平调度的时候,所有应用程序将具有相同优先级
使用公平调度的时候可以设置调度池,让不同的用户的应用运行在不同的优先级:
默认池是 default poll
job 的优先池可以如下修改:
sc.setLocalProperty(“spark.scheduler.pool”, “pool1”)添加
sc.setLocalProperty(“spark.scheduler.pool”, null) 删除
配置池的属性
添加配置文件:
conf.set(“spark.scheduler.allocation.file”, “/path/to/file”)
配置文件格式:
<?xml version=”1.0″?> 
  <allocations> 
  <pool name=”production”> 池名称
    <schedulingMode>FAIR</schedulingMode> 调度算法
    <weight>1</weight> 优先级
    <minShare>2</minShare> 最小资源分配
  </pool> 
  <pool name=”test”> 
    <schedulingMode>FIFO</schedulingMode> 
    <weight>2</weight> 
    <minShare>3</minShare> 
  </pool> 
</allocations>

更多 Spark 相关教程见以下内容

CentOS 7.0 下安装并配置 Spark  http://www.linuxidc.com/Linux/2015-08/122284.htm

Spark1.0.0 部署指南 http://www.linuxidc.com/Linux/2014-07/104304.htm

Spark 官方文档 – 中文翻译  http://www.linuxidc.com/Linux/2016-04/130621.htm

CentOS 6.2(64 位)下安装 Spark0.8.0 详细记录 http://www.linuxidc.com/Linux/2014-06/102583.htm

Spark 简介及其在 Ubuntu 下的安装使用 http://www.linuxidc.com/Linux/2013-08/88606.htm

安装 Spark 集群(在 CentOS 上) http://www.linuxidc.com/Linux/2013-08/88599.htm

Hadoop vs Spark 性能对比 http://www.linuxidc.com/Linux/2013-08/88597.htm

Spark 安装与学习 http://www.linuxidc.com/Linux/2013-08/88596.htm

Spark 并行计算模型 http://www.linuxidc.com/Linux/2012-12/76490.htm

Ubuntu 14.04 LTS 安装 Spark 1.6.0(伪分布式)http://www.linuxidc.com/Linux/2016-03/129068.htm

Spark 的详细介绍:请点这里
Spark 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-10/135869.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计3108字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中