本文转自:http://www.itweet.cn/2015/07/24/yarn-resources-manager-allocation/

Hadoop YARN同时支持内存和CPU两种资源的调度(默认只支持内存,如果想进一步调度CPU,需要自己进行一些配置),本文将介绍YARN是如何对这些资源进行调度和隔离的。

在YARN中,资源管理由ResourceManager和NodeManager共同完成,其中,ResourceManager中的调度器负责资源的分配,而NodeManager则负责资源的供给和隔离。ResourceManager将某个NodeManager上资源分配给任务(这就是所谓的“资源调度”)后,NodeManager需按照要求为任务提供相应的资源,甚至保证这些资源应具有独占性,为任务运行提供基础的保证,这就是所谓的资源隔离。
YARN会管理集群中所有机器的可用计算资源. 基于这些资源YARN会调度应用
(比如MapReduce)发来的资源请求,然后YARN会通过分配Container来给每个应用
提供处理能力, Container是YARN中处理能力的基本单元, 是对内存, CPU等的封装.

日志:

Container [pid=134663,containerID=container_1430287094897_0049_02_067966] is running beyond physical memory limits. Current usage: 1.0 GB of 1 GB physical memory used; 1.5 GB of 10 GB virtual memory used. Killing container. Dump of the process-tree for

Error: Java heap space

问题1:Container xxx is running beyond physical memory limits
问题2:java heap space

优化原则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--调节参数列表

 • Yarn 
- nodemanager:
> CPU:yarn.nodemanager.resource.cpu-vcores = 8
> 内存:yarn.nodemanager.resource.memory-mb = 8G
- resourcermanager
> 资源分配尽量与NodeManager端保持一致 • Map Tasks:
> mapreduce.map.memory.mb=2240 # Container size
> mapreduce.map.java.opts=-Xmx2016m # JVM arguments for a Map task;mapreduce.map.memory.mb*0.85
> mapreduce.map.cpu.vcores=1 • Reduce Tasks:
> mapreduce.reduce.memory.mb=2240 # Container size
> mapreduce.reduce.java.opts=-Xmx2016m # JVM arguments for a Reduce task;mapreduce.map.memory.mb*0.85
> mapreduce.reduce.cpu.vcores=1 • MapReduce Application Master
> yarn.app.mapreduce.am.resource.mb=2240 # Container size
> yarn.app.mapreduce.am.command-opts=-Xmx2016m # JVM arguments for an Application Master
> yarn.app.mapreduce.am.resource.cpu-vcores=1 • Trouble Shooting
> yarn.nodemanager.vmem-pmem-ratio
> yarn.nodemanager.vmem-check-enabled • Client
> mapreduce.job.reduces = (节点数 * reduce slot数) 的倍数 > mapreduce.client.submit.file.replication > 编码
- mapreduce.output.fileoutputformat.compress.codec
- mapreduce.map.output.compress.codec
- mapreduce.output.fileoutputformat.compress.type
* org.apache.hadoop.io.compress.DefaultCodec
* org.apache.hadoop.io.compress.SnappyCodec #最佳选择
* org.apache.hadoop.io.compress.BZip2Codec / GzipCodec #压缩比例最高,但是耗时 > io.sort
- mapreduce.task.io.sort.factor
- mapreduce.task.io.sort.mb > mapreduce.map.sort.spill.percent > mapreduce.reduce.shuffle.parallelcopies > Other:io.file.buffer.szie SequenceFiles(目前比较少用,都用rcfile,parquet,orcfile) --Yarn参数调节,根据实际硬件环境分配,后面有案例
[root@server1 ~]# python yarn-utils.py -c 32 -m 128 -d 11 -k False
Using cores=32 memory=128GB disks=11 hbase=False
Profile: cores=32 memory=106496MB reserved=24GB usableMem=104GB disks=11
Num Container=20
Container Ram=5120MB
Used Ram=100GB
Unused Ram=24GB
yarn.scheduler.minimum-allocation-mb=5120
yarn.scheduler.maximum-allocation-mb=102400
yarn.nodemanager.resource.memory-mb=102400
mapreduce.map.memory.mb=5120
mapreduce.map.java.opts=-Xmx4096m
mapreduce.reduce.memory.mb=5120
mapreduce.reduce.java.opts=-Xmx4096m
yarn.app.mapreduce.am.resource.mb=5120
yarn.app.mapreduce.am.command-opts=-Xmx4096m
mapreduce.task.io.sort.mb=2048 [root@server1 ~]# python yarn-utils.py -c 32 -m 128 -d 11 -k False
Using cores=32 memory=128GB disks=11 hbase=False
Profile: cores=32 memory=106496MB reserved=24GB usableMem=104GB disks=11
Num Container=20
Container Ram=5120MB
Used Ram=100GB
Unused Ram=24GB
yarn.scheduler.minimum-allocation-mb=5120
yarn.scheduler.maximum-allocation-mb=102400
yarn.nodemanager.resource.memory-mb=102400
mapreduce.map.memory.mb=5120
mapreduce.map.java.opts=-Xmx4096m
mapreduce.reduce.memory.mb=5120
mapreduce.reduce.java.opts=-Xmx4096m
yarn.app.mapreduce.am.resource.mb=5120
yarn.app.mapreduce.am.command-opts=-Xmx4096m
mapreduce.task.io.sort.mb=2048 --参数含义:
Option Description
-c CORES The number of cores on each host.
-m MEMORY The amount of memory on each host in GB.
-d DISKS The number of disks on each host.
-k HBASE "True" if HBase is installed, "False" if not. -- YARN以及MAPREDUCE所有可用的内存资源应该要除去系统运行需要的以及其他的hadoop的一些程序,总共保留的内存=系统内存+HBASE内存。 服务器总内存 系统需要内存 HBase需要内存
4GB 1GB 1GB
8GB 2GB 1GB
16GB 2GB 2GB
24GB 4GB 4GB
48GB 6GB 8GB
64GB 8GB 8GB
72GB 8GB 8GB
96GB 12GB 16GB
128GB 24GB 24GB
255GB 32GB 32GB
512GB 64GB 64GB

优化前:

yarn.nodemanager.resource.memory-mb
8GB
yarn.nodemanager.resource.cpu-vcores
32core

pre Mapper
CPU:1 [mapreduce.map.cpu.vcores ]
MEM:1G [mapreduce.map.memory.mb ]
===> 8 map slot / node pre Reducer
CPU:1 [mapreduce.reduce.cpu.vcores]
MEM:1G [mapreduce.reduce.memory.mb]
===> 8 reduce slot / node 【有8G内存,实际有CPU 32个,所以只能启动8个reduce在每个node上】
  • map slot / reduce slot 由nodemanager的内存/CPU core上限与客户
    端设置的单mapper, reducer内存/CPU使用值决定
  • heapsize( java.opts中的-Xmx)应根据单mapper, reducer内存进
    行调整,而与slot个数无关 => heapsize不能大于memory.mb值,一
    般设置为memory.mb的85%左右

OOM

•内存、Heap
需要设置:
-内存:mapreduce.map.memory.mb
–Heap Size:-Xmx在mapreduce.map.java.opts做相同调整
–内存:mapreduce.reduce.memory.mb
–Heap Size:-Xmx在mapreduce.reduce.java.opts做相同调整

Container 超过了虚拟内存的使用限制

– Container XXX is running beyond virtual memory limits
• NodeManager端设置,类似系统层面的overcommit问题
–yarn.nodemanager.vmem-pmem-ratio 【默认2.1,我们的做法呢【物理内存和虚拟内存比率】值为了15,yarn-site.xml中修改】

<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>10</value>
</property>
–或者yarn.nodemanager.vmem-check-enabled,false掉
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>

调优后:

mapreduce.map.java.opts, mapreduce.map.java.opts.max.heap=1.6G
mapreduce.reduce.java.opts,mapreduce.reduce.java.opts.max.heap=3.3G
注意上面两个参数和下面的mapper,reducer的内存有关系,是下面mem的0.85倍!

yarn.nodemanager.resource.memory-mb=32GB
yarn.nodemanager.resource.cpu-vcores=32core

pre Mapper
CPU:2 [mapreduce.map.cpu.vcores ]
MEM:2G [mapreduce.map.memory.mb ]
===> 16 map slot / node pre Reducer
CPU:4 [mapreduce.reduce.cpu.vcores]
MEM:4G [mapreduce.reduce.memory.mb]
==> 8 reduce slot / node

shuffle.parallelcopies如何计算?

(reduce.shuffle并行执行的副本数,最大线程数–sqrt(节点数 map slot数) 与 (节点数 map slot数)/2 之间 ==>结果:{12-72}
mapreduce.reduce.shuffle.parallelcopies=68

1
2
3
4
5
`排序文件时要合并的流的数量。也就是说,在 reducer 端合并排序期间要使用的排序头
数量。此设置决定打开文件句柄数。并行合并更多文件可减少合并排序迭代次数并通过消
除磁盘 I/O 提高运行时间。注意:并行合并更多文件会使用更多的内存。如 'io.sort.
factor' 设置太高或最大 JVM 堆栈设置太低,会产生过多地垃圾回收。Hadoop 默认值为
10,但 Cloudera 建议使用更高值。将是生成的客户端配置的一部分。`

mapreduce.task.io.sort.factor=64

xml配置
yarn.nodemanager.vmem-pmem-ratio=10 # yarn-site.xml 的 YARN 客户端高级配置
mapreduce.task.timeout=1800000

impala调优

Impala 暂存目录:需要注意此目录磁盘空间问题!最好在单独的一个挂载点!

1、内存

-服务器端(impalad)
Mem:default_query_options MEM_LIMIT=128g

2、并发查询

queue
.queue_wait_timeout_ms默认只有60s
- queue_wait_timeout_ms=600000
.default pool设置

3、资源管理

-Dynamic Resource Pools
.并发控制:max running queries

4、yarn资源隔离

http://hadoop.apache.org/docs/r2.7.1/hadoop-yarn/hadoop-yarn-site/NodeManagerCgroups.html

参考:http://www.itweet.cn

yarn资源调度(网络搜集)的更多相关文章

  1. Yarn资源调度过程详细

    在MapReduce1.0中,我们都知道也存在和HDFS一样的单点故障问题,主要是JobTracker既负责资源管理,又负责任务分配. Yarn中可以添加多种计算框架,Hadoop,Spark,Map ...

  2. 第1节 yarn:13、yarn资源调度的介绍

    Yarn资源调度 yarn集群的监控管理界面: http://192.168.52.100:8088/cluster jobHistoryServer查看界面: http://192.168.52.1 ...

  3. [大数据之Yarn]——资源调度浅学

    在hadoop生态越来越完善的背景下,集群多用户租用的场景变得越来越普遍,多用户任务下的资源调度就显得十分关键了.比如,一个公司拥有一个几十个节点的hadoop集群,a项目组要进行一个计算任务,b项目 ...

  4. YARN资源调度器

    YARN资源调度器 转载请注明出处:http://www.cnblogs.com/BYRans/ 概述 集群资源是非常有限的,在多用户.多任务环境下,需要有一个协调者,来保证在有限资源或业务约束下有序 ...

  5. Yarn 资源调度框架

    Yarn 资源调度框架    实现对资源的细粒度封装(cpu,内存,带宽)    此外,还可以通过yarn协调多种不同计算框架(MR,Spark)    概述        Apache Hadoop ...

  6. Hadoop学习之路(8)Yarn资源调度系统详解

    文章目录 1.Yarn介绍 2.Yarn架构 2.1 .ResourceManager 2.2 .ApplicationMaster 2.3 .NodeManager 2.4 .Container 2 ...

  7. spark on yarn 资源调度(cdh为例)

    一.CPU配置: ApplicationMaster 虚拟 CPU内核 yarn.app.mapreduce.am.resource.cpu-vcores ApplicationMaster占用的cp ...

  8. Hadoop(23)-Yarn资源调度器

    Yarn是一个资源调度平台,负责为运算程序提供服务器运算资源,相当于一个分布式的操作系统平台,而MapReduce等运算程序则相当于运行于操作系统之上的应用程序 1. Yarn工作机制 机制详解 第1 ...

  9. Yarn 资源调度器

    1. 概述 YARN 是一个资源调度平台,负责为运算程序提供服务器运算资源: YARN 由ResourceManager,NodeManager, ApplicationMaster 和 Contai ...

随机推荐

  1. Sql自动生成字母加数字的随机数

    /* select char(65+ceiling(rand()*25)) --随机字母(大写) select char(97+ceiling(rand()*25)) --随机字母(小写) selec ...

  2. 哈希表的C语言实现

    首先介绍一下什么是哈希表.同线性表.树一样,哈希表也是一种数据结构,理想情况下可以不需要任何比较,一次存取便能得到所查记录.所以它的优点就是查找特定记录的速度快.因为哈希表是基于数组的,所以创建后就难 ...

  3. openStack Use Orchestration module(heat) create and manage cloud resources

  4. struts接收参数方式

    第一种,直接用action的属性接收,是初学者常用的方法. package com.starain.user; public class User{ private String username; ...

  5. linux下安装mysql-community后起不来

    wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpmrpm -ivh http://repo.mysql.com/my ...

  6. 区分width()、css('width')、innerWidth()

    #widthTest1 { width: 200px; height: 200px; background-color: #00CCFF; -webkit-box-sizing: border-box ...

  7. test_wifi

    #!/system/bin/sh #Load driver echo "ASD WIFI TESTING..." AP_NAME="default" num=0 ...

  8. 使用EMOJI表情

    因为IOS系统支持日文中的字块编码,所以在UILable,UITextField,UIAlertView等控件中使用emoji表情编码(emoji就是表情符号:词义来自日语(えもじ,e-moji,mo ...

  9. [AngularJS] ngPluralize

    ngPluralize is a directive that displays messages according to en-US localization rules. <script& ...

  10. android实现界面左右滑动(GridView动态设置item,支持每个item按某个属性排序来显示在不同的界面)

    效果图 :                         分别是第一页.第二页.第三页,随手截的图,不整齐,勿见怪.开始走了弯路,废了不少时间. 思路如下: 1.用ViewPager实现左右分页滑动 ...