大数据之Hadoop集群中Yarn常用命令

Yarn状态的查询,除了可以在hadoop103:8088页面查看以外,还可以通过命令操作。常见的命令操作如下所示。

启动集群
[hadoop@hadoop102 bin]$ myhadoop.sh start
运行wordcount案例
[hadoop@hadoop102 hadoop-3.1.3]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount /input /output

1、列出所有Application:

[hadoop@hadoop102 hadoop-3.1.3]$ yarn application -list
2022-06-06 16:51:19,896 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Total number of applications (application-types: [], states: [SUBMITTED, ACCEPTED, RUNNING] and tags: []):0
                Application-Id      Application-Name        Application-Type          User           Queue                   State              Final-State             Progress                        Tracking-URL

2、根据Application状态过滤: yarn application -list -appStates [ALL、NEW、NEW_SAVING、SUBMITTED、ACCEPTED、RUNNING、FINISHED、FAILED、KILLED]

[hadoop@hadoop102 hadoop-3.1.3]$ yarn application -list -appStates FINISHED
2022-06-06 16:53:49,886 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Total number of applications (application-types: [], states: [FINISHED] and tags: []):2
                Application-Id      Application-Name        Application-Type          User           Queue                   State              Final-State             Progress                        Tracking-URL
application_1654496324557_0001            word count               MAPREDUCE        hadoop         default                FINISHED                   FAILED                 100% http://hadoop102:19888/jobhistory/job/job_1654496324557_0001
application_1654496324557_0002            word count               MAPREDUCE        hadoop         default                FINISHED                   FAILED                 100% http://hadoop102:19888/jobhistory/job/job_1654496324557_0002

2、Kill掉Application

[hadoop@hadoop102 hadoop-3.1.3]$ yarn application -kill application_1654496324557_0001
2022-06-06 16:57:34,082 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Application application_1654496324557_0001 has already finished

1、查询Application日志: yarn logs -applicationId <applicationid></applicationid>

[hadoop@hadoop102 hadoop-3.1.3]$ yarn logs -applicationId application_1654496324557_0001

2、查询Container日志: yarn logs -applicationId <applicationid> -containerId <containerid></containerid></applicationid>

[hadoop@hadoop102 hadoop-3.1.3]$ yarn logs -applicationId application_1654496324557_0001 -containerId container_1654496324557_0001_01_000001

1、列出所有Application尝试的列表: yarn applicationattempt -list <applicationid></applicationid>

[hadoop@hadoop102 hadoop-3.1.3]$ yarn applicationattempt -list application_1654496324557_0001
2022-06-06 17:05:10,914 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Total number of application attempts :1
         ApplicationAttempt-Id                 State                        AM-Container-Id                            Tracking-URL
appattempt_1654496324557_0001_000001                FINISHED    container_1654496324557_0001_01_000001  http://hadoop103:8088/proxy/application_1654496324557_0001/

2、打印ApplicationAttempt状态: yarn applicationattempt -status <applicationattemptid></applicationattemptid>

[hadoop@hadoop102 hadoop-3.1.3]$ yarn applicationattempt -status appattempt_1654496324557_0001_000001
2022-06-06 17:08:56,570 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Application Attempt Report :
        ApplicationAttempt-Id : appattempt_1654496324557_0001_000001
        State : FINISHED
        AMContainer : container_1654496324557_0001_01_000001
        Tracking-URL : http://hadoop103:8088/proxy/application_1654496324557_0001/
        RPC Port : 32771
        AM Host : hadoop103
        Diagnostics : Task failed task_1654496324557_0001_m_000000
Job failed as tasks failed. failedMaps:1 failedReduces:0 killedMaps:0 killedReduces: 0

1、列出所有Container: yarn container -list <applicationattemptid></applicationattemptid>

[hadoop@hadoop103 ~]$ yarn container -list appattempt_1654496324557_0004_000001
2022-06-06 17:14:40,313 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Total number of containers :2
                  Container-Id            Start Time             Finish Time                   State                    Host       Node Http Address                                 LOG-URL
container_1654496324557_0004_01_000001  星期一 六月 06 17:13:55 +0800 2022                       N/A                 RUNNING         hadoop102:46450     http://hadoop102:8042   http://hadoop102:8042/node/containerlogs/container_1654496324557_0004_01_000001/hadoop
container_1654496324557_0004_01_000004  星期一 六月 06 17:14:38 +0800 2022                       N/A                 RUNNING         hadoop103:44058     http://hadoop103:8042   http://hadoop103:8042/node/containerlogs/container_1654496324557_0004_01_000004/hadoop

2、打印Container状态: yarn container -status <containerid></containerid>

[hadoop@hadoop103 ~]$ yarn container -status container_1654496324557_0006_01_000001
2022-06-06 17:20:51,357 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Container Report :
        Container-Id : container_1654496324557_0006_01_000001
        Start-Time : 1654507199188
        Finish-Time : 0
        State : RUNNING
        Execution-Type : GUARANTEED
        LOG-URL : http://hadoop103:8042/node/containerlogs/container_1654496324557_0006_01_000001/hadoop
        Host : hadoop103:44058
        NodeHttpAddress : http://hadoop103:8042
        Diagnostics : null

注:只有任务跑的途中才能看到container的状态

[hadoop@hadoop103 ~]$ yarn node -list -all
2022-06-06 17:25:20,336 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Total Nodes:3
         Node-Id             Node-State Node-Http-Address       Number-of-Running-Containers
 hadoop104:38945                RUNNING    hadoop104:8042                                  0
 hadoop103:44058                RUNNING    hadoop103:8042                                  0
 hadoop102:46450                RUNNING    hadoop102:8042                                  0

加载队列配置: yarn rmadmin -refreshQueues

[hadoop@hadoop103 ~]$ yarn rmadmin -refreshQueues
2022-06-06 17:27:10,830 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8033

打印队列信息: yarn queue -status <queuename></queuename>

[hadoop@hadoop103 ~]$ yarn queue -status default
2022-06-06 17:28:54,282 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.10.103:8032
Queue Information :
Queue Name : default
        State : RUNNING
        Capacity : 100.0%
        Current Capacity : .0%
        Maximum Capacity : 100.0%
        Default Node Label expression :
        Accessible Node Labels : *
        Preemption : disabled
        Intra-queue Preemption : disabled

Original: https://www.cnblogs.com/sw-code/p/16387038.html
Author: sw-code
Title: 大数据之Hadoop集群中Yarn常用命令

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/585572/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • linux 使用mailx发送邮件

    1.安装对应的工具 [root@CentOS7 ~]# yum install postfix mailx -y [root@CentOS7 ~]# systemctl enabl…

    Linux 2023年6月7日
    0108
  • 迭代

    1.迭代的概念: 迭代是重复反馈过程的活动,其目的通常是为了逼近所需目标或结果。每一次对过程的重复称为一次”迭代”,而每一次迭代得到的结果会作为下一次迭代的…

    Linux 2023年6月8日
    0114
  • 多级缓存-redis缓存预热

    冷启动:服务刚刚启动时,Redis中并没有缓存,如果所有商品数据都在第一次查询时添加缓存,可能会给数据库带来较大压力。 缓存预热:在实际开发中,我们可以利用大数据统计用户访问的热点…

    Linux 2023年5月28日
    099
  • shell 获取变量是什么数据类型

    bash;gutter:true; function check(){ local a="$1" printf "%d" "$a&…

    Linux 2023年5月28日
    094
  • 用户相关命令

    关机重启命令均需要root权限执行 su username: 切换用户,不带任何参数会进入root;低权限用户切换高权限用户需要输入密码 logout: 只能在shell上使用,不…

    Linux 2023年6月6日
    0143
  • 记一次burp suite文件上传漏洞实验

    一·文件上传漏洞概念文件上传漏洞是指 Web 服务器允许用户在没有充分验证文件名称、类型、内容或大小等内容的情况下将文件上传到其文件系统。未能正确执行这些限制可能意味着即使是基本的…

    Linux 2023年6月7日
    0110
  • Redis 缓存更新一致性

    在使用 Redis 作为数据库缓存的场景中对数据的读取流程通常是先读取缓存如果命中则返回,未命中则从数据库读取并把数据写到缓存中。 当更新数据时则数据库和缓存都要进行更新,此时我们…

    Linux 2023年5月28日
    099
  • ES6

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> &lt…

    Linux 2023年6月13日
    0102
  • CH9102与CP2102应用注意事项

    CH9102(WCH)与CP2102的不同子型号之间可实现pintopin兼容,可以在不更改硬件设计的前提下实现不同型号间快速切换与产品应用。CH9102的子型号包括:CH9102…

    Linux 2023年6月7日
    0103
  • Centos8安装docker报错(错误提示:All mirrors were tried)

    Centos8从零安装Docker-ce 背景:我把服务器整个yum源的配置文件里的内容全删了。因为我一直碰到”All mirrors were tried&#8221…

    Linux 2023年5月27日
    0165
  • Golang中字符串、数组、切片排序

    使用Golang的sort包用来排序,包括二分查找等操作。下面通过实例代码来分享下sort包的使用技巧: 使用接口排序: sort.Sort(data Interface) 自定义…

    Linux 2023年6月6日
    0117
  • Linux基础03

    一些常见目录 usr目录 /usr/local/ # ⽤于保存⽤户安装软件程序信息 相当于windos中D:\Program Files (x86) linux系统安装软件的四种方…

    Linux 2023年6月7日
    098
  • 【深度学习】ml_collections报错

    在一些源码中,看见了一个导入: import ml_collections 此时会报错,这个包并不是PyTorch的包,同时也非源码中模块 解决办法: pip install ml…

    Linux 2023年6月13日
    092
  • CentOS7.6下Oracle19C RAC集群詳細搭建步驟

    CentOS7.6搭建RAC 1.系统环境配置 1.1概述 ​ 搭建两个节点的rac集群,其每个节点均有两个网卡,public网卡和private网卡。两个节点的主机名分别为rac…

    Linux 2023年6月13日
    080
  • 【Linux】CMake源码编译安装教程

    步骤: 卸载旧版本 官网下载安装包 CMake源码编译安装 检查是否安装成功 Linux下,默认安装方式: sudo apt install cmake 如果使用默认的安装方式,这…

    Linux 2023年6月13日
    0110
  • CentOS7.4安装docker

    1、安装环境 此处在Centos7进行安装,可以使用以下命令查看CentOS版本 lsb_release -a 在 CentOS 7安装docker要求系统为64位、系统内核版本为…

    Linux 2023年5月27日
    098
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球