创建并使用作业模板启动作业运行
这一部分说明了如何通过 Amazon Command Line Interface(Amazon CLI)创建任务模板以及使用模板启动任务运行。
创建任务模板
-
创建一个
create-job-template-request.json文件并指定任务模板所需的参数,如下面的示例 JSON 文件所示。有关所有可用参数的信息,请参阅 CreateJobTemplate API。StartJobRunAPI 所需的大多数值也是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/" } } } } } -
使用
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-id123456\ --namemyjob\ --job-template-id1234abcd