MAPREDUCE服务 MRS-Spark REST API接口介绍:REST接口
REST接口
通过以下命令可跳过REST接口过滤器获取相应的应用信息。
- 安全模式下,JobHistory仅支持https协议,故在如下命令的url中请使用https协议。
- 安全模式下,需要设置spark.ui.customErrorPage=false并重启spark2x服务 (JobHistory2x、JD BCS erver2x和SparkResource2x三个实例对应的参数都需要修改)。
- 下载curl安装包(http://curl.haxx.se/download/)。
- 使用如下命令进行安装包解压:
- 使用如下命令覆盖安装:
./configure
make
make install
- 使用如下命令更新curl的动态链接库:
- 安装成功后,重新登录节点环境,使用如下命令查看curl版本是否更新成功:
- 获取JobHistory中所有应用信息:
- 命令:
curl -k -i --negotiate -u: "https://192.168.227.16:18080/api/v1/applications"
其中192.168.227.16为JobHistory节点的业务IP,18080为JobHistory的端口号。
- 结果:
[ { "id" : "application_1517290848707_0008", "name" : "Spark Pi", "attempts" : [ { "startTime" : "2018-01-30T15:05:37.433 CS T", "endTime" : "2018-01-30T15:06:04.625CST", "lastUpdated" : "2018-01-30T15:06:04.848CST", "duration" : 27192, "sparkUser" : "sparkuser", "completed" : true, "startTimeEpoch" : 1517295937433, "endTimeEpoch" : 1517295964625, "lastUpdatedEpoch" : 1517295964848 } ] }, { " id" : "application_1517290848707_0145", "name" : "Spark shell", "attempts" : [ { "startTime" : "2018-01-31T15:20:31.286CST", "endTime" : "1970-01-01T07:59:59.999CST", "lastUpdated" : "2018-01-31T15:20:47.086CST", "duration" : 0, "sparkUser" : "admintest", "completed" : false, "startTimeEpoch" : 1517383231286, "endTimeEpoch" : -1, "lastUpdatedEpoch" : 1517383247086 } ] }]
- 结果分析:
- 命令:
- 获取JobHistory中某个应用的信息:
- 命令:
curl -k -i --negotiate -u: "https://192.168.227.16:18080/api/v1/applications/application_1517290848707_0008"
其中192.168.227.16为JobHistory节点的业务IP,18080为JobHistory的端口号,application_1517290848707_0008为应用的id。
- 结果:
{ "id" : "application_1517290848707_0008", "name" : "Spark Pi", "attempts" : [ { "startTime" : "2018-01-30T15:05:37.433CST", "endTime" : "2018-01-30T15:06:04.625CST", "lastUpdated" : "2018-01-30T15:06:04.848CST", "duration" : 27192, "sparkUser" : "sparkuser", "completed" : true, "startTimeEpoch" : 1517295937433, "endTimeEpoch" : 1517295964625, "lastUpdatedEpoch" : 1517295964848 } ] }
- 结果分析:
通过这个命令,可以查询某个Spark应用的信息,显示的信息如表1所示。
- 命令:
- 获取正在执行的某个应用的Executor信息:
- 针对alive executor命令:
curl -k -i --negotiate -u: "https://192.168.169.84:8090/proxy/application_1478570725074_0046/api/v1/applications/application_1478570725074_0046/executors"
- 针对全部executor(alive&dead)命令:
curl -k -i --negotiate -u: "https://192.168.169.84:8090/proxy/application_1478570725074_0046/api/v1/applications/application_1478570725074_0046/allexecutors"
其中192.168.169.84为ResourceManager主节点的业务IP,8090为ResourceManager的端口号,application_1478570725074_0046为在YARN中的应用ID。
- 结果:
[{ "id" : "driver", "hostPort" : "192.168.169.84:23886", "isActive" : true, "rddBlocks" : 0, "memoryUsed" : 0, "diskUsed" : 0, "activeTasks" : 0, "failedTasks" : 0, "completedTasks" : 0, "totalTasks" : 0, "totalDuration" : 0, "totalInputBytes" : 0, "totalShuffleRead" : 0, "totalShuffleWrite" : 0, "maxMemory" : 278019440, "executorLogs" : { } }, { "id" : "1", "hostPort" : "192.168.169.84:23902", "isActive" : true, "rddBlocks" : 0, "memoryUsed" : 0, "diskUsed" : 0, "totalCores" : 1, "maxTasks" : 1, "activeTasks" : 0, "failedTasks" : 0, "completedTasks" : 0, "totalTasks" : 0, "totalDuration" : 0, "totalGCTime" : 139, "totalInputBytes" : 0, "totalShuffleRead" : 0, "totalShuffleWrite" : 0, "maxMemory" : 555755765, "executorLogs" : { "stdout" : "https://XTJ-224:8044/node/containerlogs/container_1478570725074_0049_01_000002/admin/stdout?start=-4096", "stderr" : "https://XTJ-224:8044/node/containerlogs/container_1478570725074_0049_01_000002/admin/stderr?start=-4096" } } ]
- 结果分析:
- 针对alive executor命令: