Yarn命令
Apache Hadoop YARN(Yet Another Resource Negotiator)是用于集群资源管理和作业调度的核心组件。以下是一些常用的 YARN 命令:
- 启动 YARN ResourceManager:
yarn resourcemanager
运行结果示例:
ResourceManager running as process 1234. Stop it using yarn-daemon.sh.
- 启动 YARN NodeManager:
yarn nodemanager
运行结果示例:
NodeManager running as process 5678. Stop it using yarn-daemon.sh
- 查看集群状态:
yarn rmadmin -getServiceState rm1
运行结果示例:
Standby
- 列出集群中的节点:
yarn node -list
运行结果示例:
Node-Id Node-State Node-Http-Address Number-of-Containers
node1.example.com RUNNING http://node1:8042 2
node2.example.com RUNNING http://node2:8042 0
- 列出集群中正在运行的应用程序:
yarn application -list
运行结果示例:
Total Applications:2
Application-Id Application-Name Application-Type User Queue State Final-State Progress Tracking-URL
application_1617646333047_0001 WordCount MAPREDUCE john default RUNNING UNDEFINED 50% http://node1:8088/proxy/application_1617646333047_0001/
application_1617646333047_0002 PageRank MAPREDUCE alice default FINISHED SUCCEEDED 100% http://node1:8088/proxy/application_1617646333047_0002/
- 查看应用程序详情:
yarn application -status <application_id>
运行结果示例:
Application Report :
Application-Id : application_1617646333047_0001
Application-Name : WordCount
State : RUNNING
Final-State : UNDEFINED
Tracking-URL : http://node1:8088/proxy/application_1617646333047_0001/
-
杀死应用程序:
yarn application -kill <application_id>
运行结果示例:
Killed application application_1617646333047_0001
-
查看队列信息:
yarn queue -status <queue_name>
运行结果示例:
Queue Name : root.users.john
Queue State : RUNNING
- 查看指定用户的应用程序:
yarn application -list -appStates <states> -user <username>
运行结果示例:
Total Applications:1
Application-Id Application-Name Application-Type User Queue State Final-State Progress Tracking-URL
application_1617646333047_0001 WordCount MAPREDUCE john default RUNNING UNDEFINED 50% http://node1:8088/proxy/application_1617646333047_0001/
- 查看应用程序的日志:
yarn logs -applicationId <application_id>
运行结果示例:
2024-04-18 10:15:33,059 INFO mapreduce.Job: map 50% reduce 0%
- 查看应用程序的调度信息:
运行结果示例:yarn app -showappqueues <application_id>
Queue Name : root.default
Capacity : 100.0%
Max Capacity : 100.0%
- 查看应用程序的容器信息:
yarn container -status <container_id>
运行结果示例:
ContainerId: container_e10_1617646333047_0001_01_000001
NodeHttpAddress: node1.example.com:8042
- 查看队列的配置信息:
yarn queue -status <queue_name>
运行结果示例:
Queue Name : root.users.john
Queue State : RUNNING
- 刷新节点资源:
yarn rmadmin -refreshNodes
运行结果示例:
Refreshed Nodes in the cluster
- 刷新队列信息:
yarn rmadmin -refreshQueues
运行结果示例:
Refreshed Queues in the cluster
- 暂停队列:
yarn rmadmin -refreshQueues -disableQueue <queue_name>
运行结果示例:
Queue 'root.users.john' disabled.
- 恢复队列:
yarn rmadmin -refreshQueues -enableQueue <queue_name>
运行结果示例:
Queue 'root.users.john' enabled.
- 查看 YARN ResourceManager 配置:
yarn rmadmin -getconf <config_property>
运行结果示例:
yarn.nodemanager.resource.memory-mb=8192
- 更新 YARN ResourceManager 配置:
yarn rmadmin -refreshServiceAcl
运行结果示例:
Refreshed service ACLs
- 重新加载 ResourceManager 配置:
yarn rmadmin -refreshServiceAcl
运行结果示例:
Refreshed Nodes in the cluster