命令查看yarn当前任务列表

本文详细介绍了如何在Linux环境下利用YARN进行任务管理,包括查看所有命令用法、列出正在运行的任务、终止任务、查找已完成任务及查看全部任务列表。通过具体实例,展示了YARN的强大功能。

1、说明

可以在linux任意目录下输入命令;

2、查看yarn的所有命令的使用方法

root@master /]# yarn application
20/06/24 14:44:08 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.xxx.xx:8032
Invalid Command Usage : 
usage: application
 -appStates <States>             Works with -list to filter applications
                                 based on input comma-separated list of
                                 application states. The valid application
                                 state can be one of the following:
                                 ALL,NEW,NEW_SAVING,SUBMITTED,ACCEPTED,RUN
                                 NING,FINISHED,FAILED,KILLED
 -appTypes <Types>               Works with -list to filter applications
                                 based on input comma-separated list of
                                 application types.
 -help                           Displays help for all commands.
 -kill <Application ID>          Kills the application.
 -list                           List applications. Supports optional use
                                 of -appTypes to filter applications based
                                 on application type, and -appStates to
                                 filter applications based on application
                                 state.
 -movetoqueue <Application ID>   Moves the application to a different
                                 queue.
 -queue <Queue Name>             Works with the movetoqueue command to
                                 specify which queue to move an
                                 application to.
 -status <Application ID>        Prints the status of the application.

3、查看yarn正在运行的任务列表

[root@master /]# yarn application -list
20/06/24 14:25:11 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.xxx.xx:8032
Total number of applications (application-types: [] and states: [SUBMITTED, ACCEPTED, RUNNING]):1
                Application-Id	    Application-Name	    Application-Type	      User	     Queue	             State           Final-State	       Progress	                       Tracking-URL
application_1592962175770_0004	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	           RUNNING	         UNDEFINED	            10%	         http://192.168.xxx.xx:4040

4、kill掉yarn正在运行的任务

[root@master /]# yarn application -kill application_1592962175770_0004
20/06/24 14:25:29 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.xxx.xx:8032
Killing application application_1592962175770_0004
20/06/24 14:25:30 INFO impl.YarnClientImpl: Killed application application_1592962175770_0004

5、查找yarn已经完成的任务列表

[root@master /]# yarn application -appStates finished -list
20/06/24 14:28:07 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.xxx.xx:8032
Total number of applications (application-types: [] and states: [FINISHED]):3
                Application-Id	    Application-Name	    Application-Type	      User	     Queue	             State           Final-State	       Progress	                       Tracking-URL
application_1592962175770_0001	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	          FINISHED	         SUCCEEDED	           100%	                                N/A
application_1592962175770_0002	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	          FINISHED	         SUCCEEDED	           100%	                                N/A
application_1592962175770_0003	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	          FINISHED	         SUCCEEDED	           100%	             

6、查找yarn所有任务列表

[root@master /]# yarn application -appStates ALL -list
20/06/24 14:27:37 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.xxx.xx:8032
Total number of applications (application-types: [] and states: [NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED]):4
                Application-Id	    Application-Name	    Application-Type	      User	     Queue	             State           Final-State	       Progress	                       Tracking-URL
application_1592962175770_0001	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	          FINISHED	         SUCCEEDED	           100%	                                N/A
application_1592962175770_0002	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	          FINISHED	         SUCCEEDED	           100%	                                N/A
application_1592962175770_0003	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	          FINISHED	         SUCCEEDED	           100%	                                N/A
application_1592962175770_0004	kafka2sparkStreaming2Hbase	               SPARK	      root	   default	            KILLED	            KILLED	           100%	http://master:8088/cluster/app/application_1592962175770_0004

欢迎加入【大数据技术】社区

YARN 中,查看当前资源使用情况主要涉及查看节点状态、运行中的任务以及容器的详细信息。以下是一些常用的命令: 1. **查看所有节点的状态** 使用 `yarn node -list -all` 命令可以列出集群中所有的节点及其状态,包括节点的主机名、状态(如 RUNNING 或 UNHEALTHY)、使用的资源量等信息 [^1]。 2. **查看正在运行的应用程序** 使用 `yarn application -list -appStates ALL` 命令可以查看所有应用程序的状态,包括正在运行的和已完成的任务。通过 `-appStates` 参数可以指定查看不同状态的应用程序,例如 `RUNNING` 表示正在运行任务 [^2]。 3. **查看特定应用程序的详细信息** 使用 `yarn application -status <ApplicationId>` 可以获取某个具体应用程序的详细信息,包括该应用请求的资源总量、已分配的资源以及当前运行的容器数量等 [^2]。 4. **查看容器信息** 如果需要了解某个应用程序的具体容器运行情况,可以使用 `yarn container -list <ApplicationId>` 来查看该应用程序的所有容器信息。此外,还可以通过 `yarn container -status <ContainerId>` 查看特定容器的详细状态 [^1]。 5. **查看日志信息** 为了进一步诊断资源使用问题,通常还需要查看应用程序的日志。可以通过 `yarn logs -applicationId <ApplicationId>` 获取指定应用程序的日志输出,这对于分析任务执行过程中的资源消耗非常有帮助 。 6. **查看队列资源使用情况** 如果集群配置了多个队列,则可以使用 `yarn queue -status <QueueName>` 查看特定队列的资源使用情况,包括该队列中当前运行任务数、已使用的资源容量等信息 [^1]。 ### 示例代码 以下是一个简单的脚本示例,用于自动化收集并展示 YARN 集群的基本资源使用情况: ```bash #!/bin/bash # 获取所有节点列表 echo "=== Nodes ===" yarn node -list -all # 获取所有运行中的应用程序 echo -e "\n=== Running Applications ===" yarn application -list -appStates RUNNING # 获取每个应用程序的详细状态 for app in $(yarn application -list -appStates RUNNING | grep -v "Total" | awk '{print $1}'); do echo -e "\n=== Status for Application: $app ===" yarn application -status $app done # 获取每个应用程序的日志摘要 for app in $(yarn application -list -appStates RUNNING | grep -v "Total" | awk '{print $1}'); do echo -e "\n=== Logs for Application: $app ===" yarn logs -applicationId $app | head -n 20 # 只显示前20行日志作为示例 done ``` 这个脚本会依次列出所有节点、正在运行的应用程序,并为每个应用程序打印其状态和部分日志内容,从而提供一个关于当前资源使用的概览。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郝少

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值