本文转自: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. <转>libjpeg解码内存中的jpeg数据

    转自http://my.unix-center.net/~Simon_fu/?p=565 熟悉libjpeg的朋友都知道libjpeg是一个开源的库.Linux和Android都是用libjpeg来 ...

  2. C++中的位域(bit-filed):一种节省空间的成员

    转载自:http://www.cppblog.com/suiaiguo/archive/2009/07/16/90211.html 有一种被称为位域(bit-field) 的特殊的类数据成员,它可以被 ...

  3. Java学习日记-2.5 关于0和无穷

    1. 无穷 Java中将无穷定义为浮点数,分为正负无穷,分别为POSITIVE_INFINITY和NEGATIVE_INFINITY 2. null null在java中可以理解为一个特殊的引用类型, ...

  4. King's Quest - poj 1904(强连通分量+外挂输入输出)

    题意:国王有N个儿子,每个儿子都有很多喜欢的姑娘,官员为每个王子都找了一个姑娘让他们结婚,不过国王不满意,他想知道他的每个儿子都可以和那个姑娘结婚(前提他的儿子必须喜欢那个姑娘) 分析:因为最下面一行 ...

  5. codeforces 341C Iahub and Permutations(组合数dp)

    C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. 利用powershell进行远程服务器管理(命令行模式)

    Pssession,Pssession是Windows Powershell会话的意思,一个会话,可以共享数据,提供交互式的对话,我们可以为某些命令例如Invoke-Command 制定会话来远程作业 ...

  7. android改动tab 导航 指示器颜色

    我事实上想改动的上面的蓝色条条,改成红色. 这个问题实在是困扰我了太长时间.之前參照google的这个文章: https://developer.android.com/training/basics ...

  8. gzip优化网络传输量提高传输效率[转]

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;us ...

  9. 从零开始写一个Tomcat(贰)--建立动态服务器

    上文书说道如何通过http协议建立一个静态的服务器来访问静态网页,但我们选择tomcat最主要的原因还是因为它能动态的执行servlet,这边文章将引导你实现一个能够运行servlet的服务器,这个简 ...

  10. 使用Intent实现Activity的隐式跳转

    相比于显式Intent,隐式Intent 则含蓄了许多,它并不明确指出我们想要启动哪一个活动,而是指定了一系列更为抽象的action 和category 等信息,然后交由系统去分析这个Intent,并 ...