要检查Apache spark中正在运行的应用程序,可以从URL上的Web界面检查它们:
http://<master>:8080
我的问题是如何从终端检查正在运行的应用程序,是否有任何返回应用程序状态的命令?
答案 0 :(得分:9)
如果是Spark Standalone或Apache Mesos集群管理器,则可以使用@sb0709's answer。
对于YARN,您应该使用yarn application命令:
$ yarn application -help
usage: application
-appStates <States> Works with -list to filter applications
based on input comma-separated list of
application states. The valid application
state can be one of the following:
ALL,NEW,NEW_SAVING,SUBMITTED,ACCEPTED,RUN
NING,FINISHED,FAILED,KILLED
-appTypes <Types> Works with -list to filter applications
based on input comma-separated list of
application types.
-help Displays help for all commands.
-kill <Application ID> Kills the application.
-list List applications. Supports optional use
of -appTypes to filter applications based
on application type, and -appStates to
filter applications based on application
state.
-movetoqueue <Application ID> Moves the application to a different
queue.
-queue <Queue Name> Works with the movetoqueue command to
specify which queue to move an
application to.
-status <Application ID> Prints the status of the application.
答案 1 :(得分:5)
您可以使用spark-submit --status
(如Mastering Apache Spark 2.0中所述)。
spark-submit --status [submission ID]
请参阅code of spark-submit以获取参考:
if (!master.startsWith("spark://") && !master.startsWith("mesos://")) {
SparkSubmit.printErrorAndExit(
"Requesting submission statuses is only supported in standalone or Mesos mode!")
}
答案 2 :(得分:0)
在我的情况下,我的spark应用程序远程运行在亚马逊的AWS EMR上。所以我使用Lynx命令行浏览器来访问spark应用程序的状态。 当您从一个终端提交了火花作业时,打开另一个终端并从新终端发出以下命令。
**lynx http://localhost:<4043 or other spark job port>**
答案 3 :(得分:0)
我发现可以使用REST API提交,终止和获取Spark作业的状态。 REST API在端口6066上的master上公开。
要创建作业,请使用以下curl命令:
curl -X POST http://spark-cluster-ip:6066/v1/submissions/create
--header "Content-Type:application/json;charset=UTF-8"
--data
'{
"action" : "CreateSubmissionRequest",
"appArgs" : [ "blah" ],
"appResource" : "path-to-jar-file",
"clientSparkVersion" : "2.2.0",
"environmentVariables" : { "SPARK_ENV_LOADED" : "1" },
"mainClass" : "app-class",
"sparkProperties" : {
"spark.jars" : "path-to-jar-file",
"spark.driver.supervise" : "false",
"spark.app.name" : "app-name",
"spark.submit.deployMode" : "cluster",
"spark.master" : "spark://spark-master-ip:6066"
}
}'
响应包括上述操作和submissionId
的成功或失败{
'submissionId': 'driver-20170829014216-0001',
'serverSparkVersion': '2.2.0',
'success': True,
'message': 'Driver successfully submitted as driver-20170829014216-0001',
'action': 'CreateSubmissionResponse'
}
要删除作业,请使用上面获得的submissionId:
curl -X POST http://spark-cluster-ip:6066/v1/submissions/kill/driver-driver-20170829014216-0001
响应再次包含成功/失败状态:
{
'success': True,
'message': 'Kill request for driver-20170829014216-0001 submitted',
'action': 'KillSubmissionResponse',
'serverSparkVersion': '2.2.0',
'submissionId': 'driver-20170829014216-0001'
}
要获取状态,请使用以下命令:
curl http://spark-cluster-ip:6066/v1/submissions/status/driver-20170829014216-0001
响应包括驱动程序状态 - 应用程序的当前状态:
{
"action" : "SubmissionStatusResponse",
"driverState" : "RUNNING",
"serverSparkVersion" : "2.2.0",
"submissionId" : "driver-20170829203736-0004",
"success" : true,
"workerHostPort" : "10.32.1.18:38317",
"workerId" : "worker-20170829013941-10.32.1.18-38317"
}
我发现了REST API here。