本文转自: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. LeetCode——Two Sum

    Given an array of integers, find two numbers such that they add up to a specific target number. The ...

  2. mongDB 的使用

    首先是启动 mongdb的service ,不启用的话,使用mong shell 连接的现象是: 启动服务端,指定默认的存储的位置即可: mongod  -- dbpath  F:/store  #数 ...

  3. How to make onActivityResult get called on Nested Fragment

    One of the common problem we always meet in the world of Fragment is: although we could callstartAct ...

  4. [LeetCode] 347. Top K Frequent Elements 解题思路 - Java

    Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2 ...

  5. Java中的不可变类

    概念:不可变类的意思是创建该类的实例后,该实例的属性是不可改变的.java中的8个包装类和String类都是不可变类.所以不可变类并不是指该类是被final修饰的,而是指该类的属性是被final修饰的 ...

  6. VLC网页插件添加对火狐浏览器的支持

    原文转自:http://blog.csdn.net/gsls200808/article/details/25536113 1.用<embed>标签 下面这段代码只支持火狐,不支持IE & ...

  7. EMV/PBOC 解析(二) 卡片数据读取

    上一篇简单的了解了IC智能卡的文件结构和APDU报文,这篇我们直接来读取卡内的数据.下面我们主要参照<中国金融集成电路(IC)卡规范>. 好了废话不多说,下面贴指令: (1)卡片接收一个来 ...

  8. db2 存储过程迁移方法

    大家在迁移数据库时,存储过程一般也要迁移过去,但一般有两个问题: 1. 非常多存储过程有先后关系(存储过程调用存储过程),假设存储过程数量少,还能手动操作.假设量大,那真是要疯了. 2. 存储过程过大 ...

  9. nginx+keepalived实现nginx双主高可用的负载均衡

    http://kling.blog.51cto.com/3320545/1253474 一.前言: 在互联网上面,网站为用户提供原始的内容访问,同时为用户提供交互操作.提供稳定可靠的服务,可以给用户带 ...

  10. Java 编程的动态性,第 8 部分: 用代码生成取代反射--转载

    既然您已经看到了如何使用 Javassist 和 BCEL 框架来进行 classworking (请参阅 本系列以前的一组文章), 我将展示一个实际的 classworking 应用程序.这个应用程 ...