132-Hadoop-Yarn-常用命令生产环境等配置:
Yarn常用命令:
1、启动集群
2、执行一个案例
[root@hadoop102 hadoop-3.1.4]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.4.jar wordcount /input /ouput01
3、查看结果
yarn application 查看任务
(1)列出所有 Application:
[root@hadoop102 hadoop-3.1.4]# yarn application -list
(2)根据 Application 状态过滤:yarn application -list -appStates (所有状态:ALL、NEW、
NEW_SAVING、SUBMITTED、ACCEPTED、RUNNING、FINISHED、FAILED、KILLED)
[root@hadoop102 hadoop-3.1.4]yarn application -list -appStates FINISHED
(3)Kill 掉 Application:
[root@hadoop102 hadoop-3.1.4]yarn application -kill application_1612577921195_0001
yarn logs 查看日志
(1)查询 Application 日志:yarn logs -applicationId
[root@hadoop102 hadoop-3.1.4]yarn logs -applicationId application_1612577921195_0001
(2)查询 容器Container 日志:yarn logs -applicationId -containerId
[root@hadoop102 hadoop-3.1.4]# yarn logs -applicationId application_1624455563109_0001 --containerId container_1624455563109_0001_01_000001
yarn applicationattempt 查看尝试运行的任务
(1)列出所有 Application 尝试的列表:yarn applicationattempt -list
[root@hadoop102 hadoop-3.1.4]# yarn applicationattempt -list application_1624455563109_0001
(2)打印 ApplicationAttemp 状态:yarn applicationattempt -status
[root@hadoop102 hadoop-3.1.4]# yarn applicationattempt -status appattempt_1624455563109_0001_000001
yarn container 查看容器
(1)列出所有 Container:yarn container -list
(2)打印 Container 状态:yarn container -status
注:只有在任务跑的途中才能看到 container 的状态
yarn node 查看节点状态
列出所有节点:yarn node -list -all
yarn rmadmin 更新配置 (修改队列配置的时候进行修改)
加载队列配置:yarn rmadmin -refreshQueues
yarn queue 查看队列
打印队列信息:yarn queue -status
yarn queue -status default
也可在页面查看
Yarn 生产环境核心参数
1)ResourceManager相关
yarn.resourcemanager.scheduler.class 配置调度器,默认容量
yarn.resourcemanager.scheduler.client.thread-count ResourceManager处理调度器请求的线程数量,默认50
2)NodeManager相关**
yarn.nodemanager.resource.detect-hardware-capabilities 是否让yarn自己检测硬件进行配置,默认false
yarn.nodemanager.resource.count-logical-processors-as-cores 是否将虚拟核数当作CPU核数,默认false
yarn.nodemanager.resource.pcores-vcores-multiplier
虚拟核数和物理核数乘数,例如:4核8线程,该参数就应设为2,默认1.0
yarn.nodemanager.resource.memory-mb NodeManager使用内存,默认8G
yarn.nodemanager.resource.system-reserved-memory-mb NodeManager为系统保留多少内存
以上二个参数配置一个即可
yarn.nodemanager.resource.cpu-vcores NodeManager使用CPU核数,默认8个
yarn.nodemanager.pmem-check-enabled 是否开启物理内存检查限制container,默认打开
yarn.nodemanager.vmem-check-enabled 是否开启虚拟内存检查限制container,默认打开
yarn.nodemanager.vmem-pmem-ratio 虚拟内存物理内存比例,默认2.1
3)Container相关
yarn.scheduler.minimum-allocation-mb 容器最最小内存,默认1G
yarn.scheduler.maximum-allocation-mb 容器最最大内存,默认8G
yarn.scheduler.minimum-allocation-vcores 容器最小CPU核数,默认1个
yarn.scheduler.maximum-allocation-vcores 容器最大CPU核数,默认4个
案例实操:https://www.bilibili.com/video/BV1Qp4y1n7EN?p=142