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 | string | NodeManager 的主机名 |
| totalPmemAllocatedContainersMB | long | 为容器分配的物理内存量(以 MB 为单位) |
| totalVmemAllocatedContainersMB | long | 为容器分配的虚拟内存量(以 MB 为单位) |
| totalVCoresAllocatedContainers | long | 为容器分配的虚拟内核数 |
| vmemCheckEnabled | boolean | 是否为抢占启用虚拟内存检查 |
| pmemCheckEnabled | boolean | 是否为抢占启用物理内存检查 |
| lastNodeUpdateTime | long | 收到运行状况报告的最新时间戳(自纪元以来的毫秒数) |
| nmStartupTime | long | 节点启动的时间戳(自纪元以来的毫秒数) |
| healthReport | string | 节点的诊断运行状况报告 |
| nodeHealthy | boolean | 节点是否正常的 true/false 指示符 |
| nodeManagerVersion | string | NodeManager 版本 |
| nodeManagerBuildVersion | string | 包含构建版本、用户和校验和的 NodeManager 构建字符串 |
| nodeManagerVersionBuiltOn | string | NodeManager 构建时的的时间戳(自纪元以来的毫秒数) |
| hadoopVersion | string | hadoop common 版本 |
| hadoopBuildVersion | string | 包含构建版本、用户和校验和的 Hadoop common 构建字符串 |
| hadoopVersionBuiltOn | string | 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>
应用程序资源包含有关在此 NodeManager 上运行或正在运行的特定应用程序的信息。
使用以下 URI 获取应用程序对象,该应用程序由 appid 值标识。
None
| 属性 | 数据类型 | 说明 |
|---|---|---|
| id | string | 应用程序 ID |
| 用户 | string | 启动应用程序的用户 |
| 状态 | string | 应用程序的状态 - 有效状态包括: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>
容器资源包含有关在此 NodeManager 上运行的特定容器的信息。
使用以下 URI 获取容器对象,该容器由 containerid 值标识。
None
| 属性 | 数据类型 | 说明 |
|---|---|---|
| id | string | 容器 ID |
| 状态 | string | 容器状态 - 有效状态包括:NEW、LOCALIZING、LOCALIZATION_FAILED、LOCALIZED、RUNNING、EXITED_WITH_SUCCESS、EXITED_WITH_FAILURE、KILLING、CONTAINER_CLEANEDUP_AFTER_KILL、CONTAINER_RESOURCES_CLEANINGUP、DONE |
| 节点 ID | string | 容器所在的节点的 ID |
| containerLogsLink | string | 容器日志的 http 链接 |
| 用户 | string | 启动容器的用户的用户名 |
| exitCode | int | 容器的退出代码 |
| diagnostics | string | 失败容器的诊断消息 |
| totalMemoryNeededMB | long | 容器所需的内存总量(以 MB 为单位) |
| totalVCoresNeeded | long | 容器所需的虚拟内核总数 |
| executionType | string | 容器类型,GUARANTEED 或 OPPORTUNISTIC |
| 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>