栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Yarn 生产环境核心参数配置案例

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Yarn 生产环境核心参数配置案例

文章目录
  • Yarn 生产环境核心参数配置案例
    • 需求
    • 修改yarn-site.xml配置
    • 分发
    • 重启集群
    • 执行WordCount程序

Yarn 生产环境核心参数配置案例

调整下列参数之前要拍摄Linux快照(就是保留之前的状态),否则后续的案例,还需要重写集群

右键-拍摄快照
右键-恢复到快照

需求

从1G数据中,统计每个单词出现次数。服务器3台,每台配置4G内存,4核CPU,4线程。

1G/128M=8个MapTask 1个ReduceTask 1个mrAppMaster

平均每个节点运行10个/3台≈3个任务 (4个任务,3个任务,3个任务)

修改yarn-site.xml配置



Number of threads to handle scheduler
interface.
yarn.resourcemanager.scheduler.client.thread-count
8





Enable auto-detection of node capabilities such as
memory and CPU.

yarn.nodemanager.resource.detect-hardware-capabilities
false





Flag to determine if logical processors(such as
hyperthreads) should be counted as cores. Only applicable on Linux when yarn.nodemanager.resource.cpu-vcores is set to -1 and yarn.nodemanager.resource.detect-hardware-capabilities is true.

yarn.nodemanager.resource.count-logical-processors-ascores
false





Multiplier to determine how to convert phyiscal cores to
vcores. This value is used if yarn.nodemanager.resource.cpu-vcores is set to -1(which implies auto-calculate vcores) and yarn.nodemanager.resource.detect-hardware-capabilities is set to true. The number of vcores will be calculated as number of CPUs * multiplier.

yarn.nodemanager.resource.pcores-vcores-multiplier
1.0





Amount of physical memory, in MB, that can be allocated for containers. If set to -1 and yarn.nodemanager.resource.detect-hardware-capabilities is true, it is automatically calculated(in case of Windows and Linux).In other cases, the default is 8192MB.

yarn.nodemanager.resource.memory-mb
4096





Number of vcores that can be allocated
for containers. This is used by the RM scheduler when allocating resources for containers. This is not used to limit the number of CPUs used by YARN containers. If it is set to -1 and yarn.nodemanager.resource.detect-hardware-capabilities is true, it is automatically determined from the hardware in case of Windows and Linux.In other cases, number of vcores is 8 by default.
yarn.nodemanager.resource.cpu-vcores
4





The minimum allocation for every container request at the RM in MBs. Memory requests lower than this will be set to the value of this property. Additionally, a node manager that is configured to have less memory than this value will be shut down by the resource manager.

yarn.scheduler.minimum-allocation-mb
1024





The maximum allocation for every container request at the RM in MBs. Memory requests higher than this will throw an InvalidResourceRequestException.

yarn.scheduler.maximum-allocation-mb
2048





The minimum allocation for every container request at the RM in terms of virtual CPU cores. Requests lower than this will be set to the value of this property. Additionally, a node manager that is configured to have fewer virtual cores than this value will be shut down by the
resource manager.

yarn.scheduler.minimum-allocation-vcores
1





The maximum allocation for every container request at the RM in terms of virtual CPU cores. Requests higher than this will throw an InvalidResourceRequestException.
yarn.scheduler.maximum-allocation-vcores
2




Whether virtual memory limits will be enforced for containers.
yarn.nodemanager.vmem-check-enabled
false




Ratio between virtual memory to physical memory when
setting memory limits for containers. Container allocations are
expressed in terms of physical memory, and virtual memory usage is
allowed to exceed this allocation by this ratio.

yarn.nodemanager.vmem-pmem-ratio
2.1

为什么关掉虚拟内存检查?


如图Linux系统为Java进程预留了5G,但是Java8不会去使用那部分,导致大量内存浪费。
所以在CentOS7和Java8之间不用开启。

[ranan@hadoop102 hadoop]$ pwd
/opt/module/hadoop-3.1.3/etc/hadoop

//贴入之前的代码
[ranan@hadoop102 hadoop]$ vim yarn-site.xml
分发

三台服务器硬件配置一样,可以直接分发

[ranan@hadoop102 hadoop]$ xsync yarn-site.xml

xsync编写记录

重启集群
//重启集群
[ranan@hadoop102 hadoop]$ myhadoop.sh start

myhadoop.sh

#!/bin/bash 
  

# $#获取输入的参数个数 小于1
if [ $# -lt 1 ]
then
    echo "No Args Input..." 
    exit ;
fi



# $1表示第一个参数
case $1 in
"start")
        echo " =================== 启动 hadoop 集群 ===================" 

        echo " --------------- 启动 hdfs ---------------"
        # ssh无密访问其他服务器 
        ssh hadoop102 "/opt/module/hadoop-3.1.3/sbin/start-dfs.sh"
        echo " --------------- 启动 yarn ---------------" 
        ssh hadoop103 "/opt/module/hadoop-3.1.3/sbin/start-yarn.sh"
        echo " --------------- 启动 historyserver ---------------" 
        ssh hadoop102 "/opt/module/hadoop-3.1.3/bin/mapred --daemon start historyserver"
;;
"stop")
        echo " =================== 关闭 hadoop 集群 ===================" 

        echo " --------------- 关闭 historyserver ---------------" 
        ssh hadoop102 "/opt/module/hadoop-3.1.3/bin/mapred --daemon stop historyserver"
        echo " --------------- 关闭 yarn ---------------" 
        ssh hadoop103 "/opt/module/hadoop-3.1.3/sbin/stop-yarn.sh"
        echo " --------------- 关闭 hdfs ---------------" 
        ssh hadoop102 "/opt/module/hadoop-3.1.3/sbin/stop-dfs.sh"
;;
*)
    echo "Input Args Error..."
;;
esac
执行WordCount程序

http://hadoop103:8088/cluster 查看是否配置成功与运行时状态

[ranan@hadoop102 hadoop-3.1.3]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar  wordcount /input /output
名称网址
NameNodehadoop102:9870
Yarn查看任务运行情况hadoop103:8088
历史服务器hadoop102:10020
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/866433.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号