创建和使用任务模板启动任务运行 - Amazon EMR
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

创建和使用任务模板启动任务运行

这一部分说明了如何通过 Amazon Command Line Interface(Amazon CLI)创建任务模板以及使用模板启动任务运行。

创建任务模板

  1. 创建一个 create-job-template-request.json 文件并指定任务模板所需的参数,如下面的示例 JSON 文件所示。有关所有可用参数的信息,请参阅 CreateJobTemplate API。

    StartJobRun API 所需的大多数值也是 jobTemplateData 所必需的。如果要对任何参数使用占位符并在使用任务模板调用 StartJobRun 时提供值,请参阅有关任务模板参数的下一部分内容。

    { "name": "mytemplate", "jobTemplateData": { "executionRoleArn": "iam_role_arn_for_job_execution", "releaseLabel": "emr-6.7.0-latest", "jobDriver": { "sparkSubmitJobDriver": { "entryPoint": "entryPoint_location", "entryPointArguments": [ "argument1","argument2",...], "sparkSubmitParameters": "--class <main_class> --conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1" } }, "configurationOverrides": { "applicationConfiguration": [ { "classification": "spark-defaults", "properties": { "spark.driver.memory":"2G" } } ], "monitoringConfiguration": { "persistentAppUI": "ENABLED", "cloudWatchMonitoringConfiguration": { "logGroupName": "my_log_group", "logStreamNamePrefix": "log_stream_prefix" }, "s3MonitoringConfiguration": { "logUri": "s3://my_s3_log_location/" } } } } }
  2. 使用 create-job-template 命令和存储在本地的 create-job-template-request.json 文件路径。

    aws emr-containers create-job-template \ --cli-input-json file://./create-job-template-request.json

使用任务模板启动任务运行

StartJobRun 命令中提供虚拟集群 ID、任务模板 ID 和任务名称,如以下示例所示。

aws emr-containers start-job-run \ --virtual-cluster-id 123456 \ --name myjob \ --job-template-id 1234abcd