NodeManager REST API 允許使用者取得節點狀態,以及在該節點上執行的應用程式和容器的資訊。
若要僅為 NM 啟用跨來源支援 (CORS)(不為 RM 啟用),請設定下列組態參數
在 core-site.xml 中,將 org.apache.hadoop.security.HttpCrossOriginFilterInitializer 加入 hadoop.http.filter.initializers。在 yarn-site.xml 中,將 yarn.nodemanager.webapp.cross-origin.enabled 設定為 true。
節點資訊資源提供有關特定節點的整體資訊。
下列兩個 URI 都會提供叢集資訊。
None
屬性 | 資料類型 | 說明 |
---|---|---|
id | long | NodeManager ID |
nodeHostName | 字串 | NodeManager 的主機名稱 |
totalPmemAllocatedContainersMB | long | 以 MB 為單位的容器分配實體記憶體量 |
totalVmemAllocatedContainersMB | long | 以 MB 為單位的容器分配虛擬記憶體量 |
totalVCoresAllocatedContainers | long | 容器分配的虛擬核心數 |
vmemCheckEnabled | 布林值 | 是否已啟用虛擬記憶體檢查以進行搶先 |
pmemCheckEnabled | 布林值 | 是否已啟用實體記憶體檢查以進行搶先 |
lastNodeUpdateTime | long | 收到健康報告的最後時間戳記 (自紀元以來的毫秒數) |
nmStartupTime | long | 節點啟動的時間戳記 (自紀元以來的毫秒數) |
healthReport | 字串 | 節點的診斷健康報告 |
nodeHealthy | 布林值 | 節點是否健康的 true/false 指示器 |
nodeManagerVersion | 字串 | NodeManager 的版本 |
nodeManagerBuildVersion | 字串 | 包含建置版本、使用者和檢查碼的 NodeManager 建置字串 |
nodeManagerVersionBuiltOn | 字串 | NodeManager 建置的時間戳記 (自紀元以來的毫秒數) |
hadoopVersion | 字串 | hadoop common 的版本 |
hadoopBuildVersion | 字串 | 包含建置版本、使用者和檢查碼的 Hadoop common 建置字串 |
hadoopVersionBuiltOn | 字串 | hadoop common 建置的時間戳記 (自紀元以來的毫秒數) |
JSON 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/info
回應標頭
HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.26)
回應主體
{ "nodeInfo": { "healthReport": "", "totalVmemAllocatedContainersMB": 17203, "totalPmemAllocatedContainersMB": 8192, "totalVCoresAllocatedContainers": 8, "vmemCheckEnabled": false, "pmemCheckEnabled": true, "lastNodeUpdateTime": 1485814574224, "nodeHealthy": true, "nodeManagerVersion": "3.0.0", "nodeManagerBuildVersion": "3.0.0", "nodeManagerVersionBuiltOn": "2017-01-30T17:42Z", "hadoopVersion": "3.0.0", "hadoopBuildVersion": "3.0.0", "hadoopVersionBuiltOn": "2017-01-30T17:39Z", "id": "host.domain.com:46077", "nodeHostName": "host.domain.com", "nmStartupTime": 1485800887841 } }
XML 回應
HTTP 要求
Accept: application/xml GET http://nm-http-address:port/ws/v1/node/info
回應標頭
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 983 Server: Jetty(6.1.26)
回應主體
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <nodeInfo> <healthReport></healthReport> <totalVmemAllocatedContainersMB>17203</totalVmemAllocatedContainersMB> <totalPmemAllocatedContainersMB>8192</totalPmemAllocatedContainersMB> <totalVCoresAllocatedContainers>8</totalVCoresAllocatedContainers> <vmemCheckEnabled>false</vmemCheckEnabled> <pmemCheckEnabled>true</pmemCheckEnabled> <lastNodeUpdateTime>1485815774203</lastNodeUpdateTime> <nodeHealthy>true</nodeHealthy> <nodeManagerVersion>3.0.0</nodeManagerVersion> <nodeManagerBuildVersion>3.0.0</nodeManagerBuildVersion> <nodeManagerVersionBuiltOn>2017-01-30T17:42Z</nodeManagerVersionBuiltOn> <hadoopVersion>3.0.0</hadoopVersion> <hadoopBuildVersion>3.0.0</hadoopBuildVersion> <hadoopVersionBuiltOn>2017-01-30T17:39Z</hadoopVersionBuiltOn> <id>host.domain.com:46077</id> <nodeHostName>host.domain.com</nodeHostName> <nmStartupTime>1485800887841</nmStartupTime> </nodeInfo>
使用應用程式 API,您可以取得資源集合,每個資源都代表一個應用程式。對此資源執行 GET 作業時,您會取得應用程式物件集合。另請參閱 應用程式 API 以取得應用程式物件的語法。
可以指定多個參數。
當您要求提供應用程式清單時,資訊會以應用程式物件集合的形式傳回。另請參閱 應用程式 API 以取得應用程式物件的語法。
屬性 | 資料類型 | 說明 |
---|---|---|
應用程式 | 應用程式物件陣列 (JSON)/零個或多個應用程式物件 (XML) | 應用程式物件集合 |
JSON 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/apps
回應標頭
HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.26)
回應主體
{ "apps" : { "app" : [ { "containerids" : [ "container_1326121700862_0003_01_000001", "container_1326121700862_0003_01_000002" ], "user" : "user1", "id" : "application_1326121700862_0003", "state" : "RUNNING" }, { "user" : "user1", "id" : "application_1326121700862_0002", "state" : "FINISHED" } ] } }
XML 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/apps Accept: application/xml
回應標頭
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 400 Server: Jetty(6.1.26)
回應主體
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <apps> <app> <id>application_1326121700862_0002</id> <state>FINISHED</state> <user>user1</user> </app> <app> <id>application_1326121700862_0003</id> <state>RUNNING</state> <user>user1</user> <containerids>container_1326121700862_0003_01_000002</containerids> <containerids>container_1326121700862_0003_01_000001</containerids> </app> </apps>
應用程式資源包含在這個節點管理程式上執行或正在執行的特定應用程式的資訊。
使用下列 URI 取得應用程式物件,針對由 appid 值識別的應用程式。
None
屬性 | 資料類型 | 說明 |
---|---|---|
id | 字串 | 應用程式 ID |
使用者 | 字串 | 啟動應用程式的使用者 |
狀態 | 字串 | 應用程式的狀態 - 有效狀態為:NEW、INITING、RUNNING、FINISHING_CONTAINERS_WAIT、APPLICATION_RESOURCES_CLEANINGUP、FINISHED |
容器 ID | 容器 ID 陣列 (JSON)/零個或多個容器 ID (XML) | 目前由這個節點上的應用程式使用的容器 ID 清單。如果不存在,則目前沒有容器為這個應用程式執行。 |
JSON 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/apps/application_1326121700862_0005
回應標頭
HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.26)
回應主體
{ "app" : { "containerids" : [ "container_1326121700862_0005_01_000003", "container_1326121700862_0005_01_000001" ], "user" : "user1", "id" : "application_1326121700862_0005", "state" : "RUNNING" } }
XML 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/apps/application_1326121700862_0005 Accept: application/xml
回應標頭
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 281 Server: Jetty(6.1.26)
回應主體
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <app> <id>application_1326121700862_0005</id> <state>RUNNING</state> <user>user1</user> <containerids>container_1326121700862_0005_01_000003</containerids> <containerids>container_1326121700862_0005_01_000001</containerids> </app>
使用容器 API,您可以取得資源集合,其中每個資源都代表一個容器。當您對這個資源執行 GET 作業時,您會取得容器物件集合。另請參閱 容器 API,以取得容器物件的語法。
None
當您要求容器清單時,資訊將會以容器物件集合的形式傳回。另請參閱 容器 API,以取得容器物件的語法。
屬性 | 資料類型 | 說明 |
---|---|---|
容器 | 容器物件陣列 (JSON)/零個或多個容器物件 (XML) | 容器物件集合 |
JSON 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/containers
回應標頭
HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.26)
回應主體
{ "containers" : { "container" : [ { "nodeId" : "host.domain.com:8041", "totalMemoryNeededMB" : 2048, "totalVCoresNeeded" : 1, "state" : "RUNNING", "diagnostics" : "", "containerLogsLink" : "http://host.domain.com:8042/node/containerlogs/container_1326121700862_0006_01_000001/user1", "user" : "user1", "id" : "container_1326121700862_0006_01_000001", "exitCode" : -1000, "executionType": "GUARANTEED", "containerLogFiles": [ "stdout", "stderr", "syslog" ] }, { "nodeId" : "host.domain.com:8041", "totalMemoryNeededMB" : 2048, "totalVCoresNeeded" : 2, "state" : "RUNNING", "diagnostics" : "", "containerLogsLink" : "http://host.domain.com:8042/node/containerlogs/container_1326121700862_0006_01_000003/user1", "user" : "user1", "id" : "container_1326121700862_0006_01_000003", "exitCode" : -1000, "executionType": "GUARANTEED", "containerLogFiles": [ "stdout", "stderr", "syslog" ] } ] } }
XML 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/containers Accept: application/xml
回應標頭
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 988 Server: Jetty(6.1.26)
回應主體
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <containers> <container> <id>container_1326121700862_0006_01_000001</id> <state>RUNNING</state> <exitCode>-1000</exitCode> <diagnostics/> <user>user1</user> <totalMemoryNeededMB>2048</totalMemoryNeededMB> <totalVCoresNeeded>1</totalVCoresNeeded> <containerLogsLink>http://host.domain.com:8042/node/containerlogs/container_1326121700862_0006_01_000001/user1</containerLogsLink> <nodeId>host.domain.com:8041</nodeId> <executionType>GUARANTEED</executionType> <containerLogFiles>stdout</containerLogFiles> <containerLogFiles>stderr</containerLogFiles> <containerLogFiles>syslog</containerLogFiles> </container> <container> <id>container_1326121700862_0006_01_000003</id> <state>DONE</state> <exitCode>0</exitCode> <diagnostics>Container killed by the ApplicationMaster.</diagnostics> <user>user1</user> <totalMemoryNeededMB>2048</totalMemoryNeededMB> <totalVCoresNeeded>2</totalVCoresNeeded> <containerLogsLink>http://host.domain.com:8042/node/containerlogs/container_1326121700862_0006_01_000003/user1</containerLogsLink> <nodeId>host.domain.com:8041</nodeId> <executionType>GUARANTEED</executionType> <containerLogFiles>stdout</containerLogFiles> <containerLogFiles>stderr</containerLogFiles> <containerLogFiles>syslog</containerLogFiles> </container> </containers>
容器資源包含在這個節點管理程式上執行的特定容器的資訊。
使用下列 URI 取得容器物件,從由 containerid 值識別的容器。
None
屬性 | 資料類型 | 說明 |
---|---|---|
id | 字串 | 容器 ID |
狀態 | 字串 | 容器狀態 - 有效狀態為:NEW、LOCALIZING、LOCALIZATION_FAILED、LOCALIZED、RUNNING、EXITED_WITH_SUCCESS、EXITED_WITH_FAILURE、KILLING、CONTAINER_CLEANEDUP_AFTER_KILL、CONTAINER_RESOURCES_CLEANINGUP、DONE |
節點 ID | 字串 | 容器所在的節點 ID |
容器記錄連結 | 字串 | 容器記錄的 http 連結 |
使用者 | 字串 | 啟動容器的使用者名稱 |
exitCode | int | 容器的結束代碼 |
diagnostics | 字串 | 失敗容器的診斷訊息 |
totalMemoryNeededMB | long | 容器所需的總記憶體量 (以 MB 為單位) |
totalVCoresNeeded | long | 容器所需的虛擬核心總數 |
executionType | 字串 | 保證或機會主義的容器類型 |
containerLogFiles | 字串陣列 | 容器記錄檔名稱 |
JSON 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/containers/container_1326121700862_0007_01_000001
回應標頭
HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.26)
回應主體
{ "container" : { "nodeId" : "host.domain.com:8041", "totalMemoryNeededMB" : 2048, "totalVCoresNeeded" : 1, "state" : "RUNNING", "diagnostics" : "", "containerLogsLink" : "http://host.domain.com:8042/node/containerlogs/container_1326121700862_0007_01_000001/user1", "user" : "user1", "id" : "container_1326121700862_0007_01_000001", "exitCode" : -1000, "executionType": "GUARANTEED", "containerLogFiles": [ "stdout", "stderr", "syslog" ] } }
XML 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/containers/container_1326121700862_0007_01_000001 Accept: application/xml
回應標頭
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 491 Server: Jetty(6.1.26)
回應主體
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <container> <id>container_1326121700862_0007_01_000001</id> <state>RUNNING</state> <exitCode>-1000</exitCode> <diagnostics/> <user>user1</user> <totalMemoryNeededMB>2048</totalMemoryNeededMB> <totalVCoresNeeded>1</totalVCoresNeeded> <containerLogsLink>http://host.domain.com:8042/node/containerlogs/container_1326121700862_0007_01_000001/user1</containerLogsLink> <nodeId>host.domain.com:8041</nodeId> <executionType>GUARANTEED</executionType> <containerLogFiles>stdout</containerLogFiles> <containerLogFiles>stderr</containerLogFiles> <containerLogFiles>syslog</containerLogFiles> </container>
使用輔助服務 API,您可以取得資源的集合,每個資源都代表一個輔助服務。當您對此資源執行 GET 作業時,您會取得輔助服務資訊物件的集合。
YARN 管理員可以使用 PUT 作業更新在 NodeManager 上執行的輔助服務。要求的主體應與輔助服務清單檔案的格式相同。
None
當您提出輔助服務清單的請求時,資訊將會以服務資訊物件的集合傳回。
屬性 | 資料類型 | 說明 |
---|---|---|
services | 服務資訊物件陣列 (JSON)/零個或多個服務資訊物件 (XML) | 服務資訊物件的集合 |
JSON 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/auxiliaryservices
回應標頭
HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.26)
回應主體
{ "services": { "service": [ { "name": "timeline_collector", "startTime": "2018-12-18 21:24:27", "version": "1" }, { "name": "mapreduce_shuffle", "startTime": "2018-12-18 21:24:27", "version": "2" } ] } }
XML 回應
HTTP 要求
GET http://nm-http-address:port/ws/v1/node/auxiliaryservices Accept: application/xml
回應標頭
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: 299 Server: Jetty(6.1.26)
回應主體
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <services> <service> <name>timeline_collector</name> <version>1</version> <startTime>2018-12-18 21:00:00</startTime> </service> <service> <name>mapreduce_shuffle</name> <version>2</version> <startTime>2018-12-18 21:00:00</startTime> </service> </services>