5

我正在使用 log4j 属性的 spark-submit 命令来调用 Spark-submit,如下所示:

/opt/spark-1.6.2-bin-hadoop2.6/bin/spark-submit \
--driver-java-options \
"-Dlog4j.configuration=file:/home/test_api/log4j-driver.properties\ --class Test testing.jar

如何--driver-java-options通过 curl(Apache Spark 的 Hidden REST API)提交作业?

我试过这个:

curl -X POST http://host-ip:6066/v1/submissions/create --header "Content-Type:application/json;charset=UTF-8" --data '{
"action" : "CreateSubmissionRequest",
"appArgs" : [ "" ],
"appResource" : "hdfs://host-ip:9000/test/testing.jar",
"clientSparkVersion" : "1.6.2",
"environmentVariables" : {
"SPARK_ENV_LOADED" : "1"
},
"mainClass" : "Test",
"spark.driver.extraJavaOptions" : "-Dlog4j.configuration=file:/home/test_api/log4j-driver.properties",
"sparkProperties" : {
"spark.jars" : "hdfs://host-ip:9000/test/testing.jar",
"spark.app.name" : "Test",
"spark.eventLog.enabled": "true",
"spark.eventLog.dir": "hdfs://host-ip:9000/test/spark-events",
"spark.submit.deployMode" : "cluster",
"spark.master" : "spark://host-ip:7077"
}
}'

作业提交成功并给出了响应,但有一个 uknownField:

{
  "action" : "CreateSubmissionResponse",
  "message" : "Driver successfully submitted as driver-20160810210057-0091",
  "serverSparkVersion" : "1.6.2",
  "submissionId" : "driver-20160810210057-0091",
  "success" : true,
  "unknownFields" : [ "spark.driver.extraJavaOptions" ]
}

"unknownFields" : [ "spark.driver.extraJavaOptions" ]

我也试过driverExtraJavaOptions如下:

curl -X POST http://host-ip:6066/v1/submissions/create --header "Content-Type:application/json;charset=UTF-8" --data '{
"action" : "CreateSubmissionRequest",
"appArgs" : [ "" ],
"appResource" : "hdfs://host-ip:9000/test/testing.jar",
"clientSparkVersion" : "1.6.2",
"environmentVariables" : {
"SPARK_ENV_LOADED" : "1"
},
"mainClass" : "Test",
"driverExtraJavaOptions" : "-Dlog4j.configuration=file:/home/test_api/log4j-driver.properties",
"sparkProperties" : {
"spark.jars" : "hdfs://host-ip:9000/test/testing.jar",
"spark.app.name" : "Test",
"spark.eventLog.enabled": "true",
"spark.eventLog.dir": "hdfs://host-ip:9000/test/spark-events",
"spark.submit.deployMode" : "cluster",
"spark.master" : "spark://host-ip:7077"
}
}'

但得到了类似的回应:

{
  "action" : "CreateSubmissionResponse",
  "message" : "Driver successfully submitted as driver-20160810211432-0094",
  "serverSparkVersion" : "1.6.2",
  "submissionId" : "driver-20160810211432-0094",
  "success" : true,
  "unknownFields" : [ "driverExtraJavaOptions" ]
}

为什么是这样?
我查看了spark-submit.scala并引用了Spark REST API

4

1 回答 1

2

现在可以将 Dlog4j.configuration=file:/// (/// 本地文件的路径)并将 spark.driver.extraJavaOptions 放入 sparkProperties

curl -X POST http://host-ip:6066/v1/submissions/create --header "Content-Type:application/json;charset=UTF-8" --data '{
"action" : "CreateSubmissionRequest",
"appArgs" : [ "" ],
"appResource" : "hdfs://host-ip:9000/test/testing.jar",
"clientSparkVersion" : "1.6.2",
"environmentVariables" : {
"SPARK_ENV_LOADED" : "1"
},
"mainClass" : "Test",
"sparkProperties" : {
"spark.jars" : "hdfs://host-ip:9000/test/testing.jar",
"spark.driver.extraJavaOptions" : "-Dlog4j.configuration=file:///home/log4j-driver.properties",
"spark.app.name" : "Test",
"spark.eventLog.enabled": "true",
"spark.eventLog.dir": "hdfs://host-ip:9000/test/spark-events",
"spark.submit.deployMode" : "client",
"spark.master" : "spark://host-ip:7077"
}
}'
于 2016-08-12T15:47:24.577 回答