【问题标题】:aws emr add-steps a spark applicationaws emr 添加步骤 spark 应用程序
【发布时间】:2021-05-30 12:09:58
【问题描述】:

我想使用 AWS CLI 添加一个步骤作为 spark 应用程序,但我找不到工作命令,来自 AWS 官方文档:https://docs.aws.amazon.com/cli/latest/reference/emr/add-steps.html,他们列出了 6 个示例,其中没有一个是用于 spark 的。 但我可以通过 AWS 控制台 UI 对其进行配置,并且运行良好,但为了提高效率,我希望能够通过 aws cli 进行配置。

我能想到的最接近的是这个命令:

aws emr add-steps --cluster-id j-cluster-id --steps  Type=SPARK,Name='SPARK APP',ActionOnFailure=CONTINUE,Jar=s3://my-test/RandomJava-1.0-SNAPSHOT.jar,MainClass=JavaParquetExample1,Args=s3://my-test/my-file_0000_part_00.parquet,my-test --profile my-test --region us-west-2

但这导致在 AWS EMR 步骤上进行此配置:

JAR location : command-runner.jar
Main class : None
Arguments : spark-submit s3://my-test/my-file_0000_part_00.parquet my-test
Action on failure: Continue

导致失败。

正确的(成功完成,通过 AWS 控制台 UI 配置)如下所示:

JAR location : command-runner.jar
Main class : None
Arguments : spark-submit --deploy-mode cluster --class sparkExamples.JavaParquetExample1 s3://my-test/RandomJava-1.0-SNAPSHOT.jar --s3://my-test/my-file_0000_part_00.parquet --my-test
Action on failure: Continue

非常感谢任何帮助!

【问题讨论】:

  • 我认为本文档包含有效示例,或者我可能没有理解您的查询docs.aws.amazon.com/emr/latest/ReleaseGuide/…
  • 在此链接中的哪个示例之后,您的命令是什么?谢谢
  • 您能否查看特定问题的日志(通过转到步骤,选择您的步骤,然后对于日志文件,选择标准输出或标准错误)

标签: amazon-web-services apache-spark aws-cli amazon-emr


【解决方案1】:

这似乎对我有用。我正在使用步骤名称My step name 将 Spark 应用程序添加到集群中。假设您将文件命名为step-addition.sh。其内容如下:

#!/bin/bash
set -x

#cluster id
clusterId=$1
startDate=$2
endDate=$3

aws emr add-steps --cluster-id $clusterId --steps Type=Spark,Name='My step name',\
ActionOnFailure=TERMINATE_CLUSTER,Args=[\
"--deploy-mode","cluster","--executor-cores","1","--num-executors","20","--driver-memory","10g","--executor-memory","3g",\
"--class","your-package-structure-like-com.a.b.c.JavaParquetExample1",\
"--master","yarn",\
"--conf","spark.driver.my.custom.config1=my-value-1",\
"--conf","spark.driver.my.custom.config2=my-value-2",\
"--conf","spark.driver.my.custom.config.startDate=${startDate}",\
"--conf","spark.driver.my.custom.config.endDate=${endDate}",\
"s3://my-bucket/my-prefix/path-to-your-actual-application.jar"]

你可以像这样简单地执行上面的脚本:

bash $WORK_DIR/step-addition.sh $clusterId $startDate $endDate

【讨论】:

    猜你喜欢
    • 2020-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 2020-12-30
    • 1970-01-01
    • 2017-03-23
    • 2017-09-11
    相关资源
    最近更新 更多