hadoop之yarn詳解(命令篇)


本篇主要對yarn命令進行闡述

一、yarn命令概述

[root@lgh ~]# yarn -help 
Usage: yarn [--config confdir] COMMAND
where COMMAND is one of:
  resourcemanager -format-state-store   deletes the RMStateStore
  resourcemanager                       run the ResourceManager
                                        Use -format-state-store for deleting the RMStateStore.
                                        Use -remove-application-from-state-store <appId> for 
                                            removing application from RMStateStore.
  nodemanager                           run a nodemanager on each slave
  timelineserver                        run the timeline server
  rmadmin                               admin tools
  version                               print the version
  jar <jar>                             run a jar file
  application                           prints application(s)
                                        report/kill application
  applicationattempt                    prints applicationattempt(s)
                                        report
  container                             prints container(s) report
  node                                  prints node report(s)
  queue                                 prints queue information
  logs                                  dump container logs
  classpath                             prints the class path needed to
                                        get the Hadoop jar and the
                                        required libraries
  daemonlog                             get/set the log level for each
                                        daemon
  top                                   run cluster usage tool
 or
  CLASSNAME                             run the class named CLASSNAME

使用語法:

yarn [--config confdir] COMMAND [--loglevel loglevel] [GENERIC_OPTIONS] [COMMAND_OPTIONS]

--config confdir        #覆蓋默認的配置目錄,默認為${HADOOP_PREFIX}/conf.
--loglevel loglevel     #覆蓋日志級別。有效的日志級別為FATAL,ERROR,WARN,INFO,DEBUG和TRACE。默認值為INFO。
GENERIC_OPTIONS         #多個命令支持的一組通用選項
COMMAND COMMAND_OPTIONS #以下各節介紹了各種命令及其選項

二、命令詳解

2.1、application

使用語法:yarn  application [options] #打印報告,申請和殺死任務

-appStates <States>         #與-list一起使用,可根據輸入的逗號分隔的應用程序狀態列表來過濾應用程序。有效的應用程序狀態可以是以下之一:ALL,NEW,NEW_SAVING,SUBMITTED,ACCEPTED,RUNNING,FINISHED,FAILED,KILLED
-appTypes <Types>           #與-list一起使用,可以根據輸入的逗號分隔的應用程序類型列表來過濾應用程序。
-list                       #列出RM中的應用程序。支持使用-appTypes來根據應用程序類型過濾應用程序,並支持使用-appStates來根據應用程序狀態過濾應用程序。
-kill <ApplicationId>       #終止應用程序。
-status <ApplicationId>     #打印應用程序的狀態。

2.2、applicationattempt

使用語法:yarn applicationattempt [options] #打印應用程序嘗試的報告

-help                    #幫助
-list <ApplicationId>    #獲取到應用程序嘗試的列表,其返回值ApplicationAttempt-Id 等於 <Application Attempt Id>
-status <Application Attempt Id>    #打印應用程序嘗試的狀態。

2.3、classpath

使用語法:yarn classpath #打印需要得到Hadoop的jar和所需要的lib包路徑

2.4、container

使用語法:yarn container [options] #打印container(s)的報告

-help                            #幫助
-list <Application Attempt Id>   #應用程序嘗試的Containers列表
-status <ContainerId>            #打印Container的狀態

2.5、jar

使用語法:yarn jar <jar> [mainClass] args... #運行jar文件,用戶可以將寫好的YARN代碼打包成jar文件,用這個命令去運行它。

2.6、logs

使用語法:yarn logs -applicationId <application ID> [options] #轉存container的日志。

-applicationId <application ID>    #指定應用程序ID,應用程序的ID可以在yarn.resourcemanager.webapp.address配置的路徑查看(即:ID)
-appOwner <AppOwner>               #應用的所有者(如果沒有指定就是當前用戶)應用程序的ID可以在yarn.resourcemanager.webapp.address配置的路徑查看(即:User)
-containerId <ContainerId>         #Container Id
-help                              #幫助
-nodeAddress <NodeAddress>         #節點地址的格式:nodename:port (端口是配置文件中:yarn.nodemanager.webapp.address參數指定)

2.7、node

使用語法:yarn node [options] #打印節點報告

-all             #所有的節點,不管是什么狀態的。
-list             #列出所有RUNNING狀態的節點。支持-states選項過濾指定的狀態,節點的狀態包含:NEW,RUNNING,UNHEALTHY,DECOMMISSIONED,LOST,REBOOTED。支持--all顯示所有的節點。
-states <States> #和-list配合使用,用逗號分隔節點狀態,只顯示這些狀態的節點信息。
-status <NodeId> #打印指定節點的狀態。

2.8、queue

使用語法:yarn queue [options] #打印隊列信息

-help     #幫助
-status  #<QueueName>    打印隊列的狀態

2.9、daemonlog

使用語法:

yarn daemonlog -getlevel <host:httpport> <classname>
yarn daemonlog -setlevel <host:httpport> <classname> <level>

-getlevel <host:httpport> <classname>            #打印運行在<host:port>的守護進程的日志級別。這個命令內部會連接http://<host:port>/logLevel?log=<name>
-setlevel <host:httpport> <classname> <level>    #設置運行在<host:port>的守護進程的日志級別。這個命令內部會連接http://<host:port>/logLevel?log=<name>

2.10、nodemanager

使用語法:yarn nodemanager #啟動nodemanager

2.11、proxyserver

使用語法:yarn proxyserver #啟動web proxy server

2.12、resourcemanager

使用語法:yarn resourcemanager [-format-state-store] #啟動ResourceManager

-format-state-store     # RMStateStore的格式. 如果過去的應用程序不再需要,則清理RMStateStore, RMStateStore僅僅在ResourceManager沒有運行的時候,才運行RMStateStore

2.13、rmadmin

使用語法: #運行Resourcemanager管理客戶端

yarn rmadmin [-refreshQueues]
              [-refreshNodes]
              [-refreshUserToGroupsMapping] 
              [-refreshSuperUserGroupsConfiguration]
              [-refreshAdminAcls] 
              [-refreshServiceAcl]
              [-getGroups [username]]
              [-transitionToActive [--forceactive] [--forcemanual] <serviceId>]
              [-transitionToStandby [--forcemanual] <serviceId>]
              [-failover [--forcefence] [--forceactive] <serviceId1> <serviceId2>]
              [-getServiceState <serviceId>]
              [-checkHealth <serviceId>]
              [-help [cmd]]
-refreshQueues    #重載隊列的ACL,狀態和調度器特定的屬性,ResourceManager將重載mapred-queues配置文件
-refreshNodes     #動態刷新dfs.hosts和dfs.hosts.exclude配置,無需重啟NameNode。
                  #dfs.hosts:列出了允許連入NameNode的datanode清單(IP或者機器名)
                  #dfs.hosts.exclude:列出了禁止連入NameNode的datanode清單(IP或者機器名)
                  #重新讀取hosts和exclude文件,更新允許連到Namenode的或那些需要退出或入編的Datanode的集合。
-refreshUserToGroupsMappings            #刷新用戶到組的映射。
-refreshSuperUserGroupsConfiguration    #刷新用戶組的配置
-refreshAdminAcls                       #刷新ResourceManager的ACL管理
-refreshServiceAcl                      #ResourceManager重載服務級別的授權文件。
-getGroups [username]                   #獲取指定用戶所屬的組。
-transitionToActive [–forceactive] [–forcemanual] <serviceId>    #嘗試將目標服務轉為 Active 狀態。如果使用了–forceactive選項,不需要核對非Active節點。如果采用了自動故障轉移,這個命令不能使用。雖然你可以重寫–forcemanual選項,你需要謹慎。
-transitionToStandby [–forcemanual] <serviceId>                  #將服務轉為 Standby 狀態. 如果采用了自動故障轉移,這個命令不能使用。雖然你可以重寫–forcemanual選項,你需要謹慎。
-failover [–forceactive] <serviceId1> <serviceId2>  #啟動從serviceId1 到 serviceId2的故障轉移。如果使用了-forceactive選項,即使服務沒有准備,也會嘗試故障轉移到目標服務。如果采用了自動故障轉移,這個命令不能使用。
-getServiceState <serviceId>                        #返回服務的狀態。(注:ResourceManager不是HA的時候,時不能運行該命令的)
-checkHealth <serviceId>                            #請求服務器執行健康檢查,如果檢查失敗,RMAdmin將用一個非零標示退出。(注:ResourceManager不是HA的時候,時不能運行該命令的)
-help [cmd]                                         #顯示指定命令的幫助,如果沒有指定,則顯示命令的幫助。

2.14、scmadmin

使用語法:yarn scmadmin [options]  #運行共享緩存管理客戶端

-help            #查看幫助
-runCleanerTask    #運行清理任務

2.15、 sharedcachemanager

使用語法:yarn sharedcachemanager #啟動共享緩存管理器

2.16、timelineserver

使用語法:yarn timelineserver   #啟動timelineserver

 

更多hadoop生態文章見: hadoop生態系列

 

參考:
https://hadoop.apache.org/docs/r2.7.7/hadoop-yarn/hadoop-yarn-site/YarnCommands.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM