不幸的是,boto3 和 EMR API 的文档记录相当差。至少,字数统计示例如下所示:
import boto3
emr = boto3.client('emr')
resp = emr.run_job_flow(
Name='myjob',
ReleaseLabel='emr-5.0.0',
Instances={
'InstanceGroups': [
{'Name': 'master',
'InstanceRole': 'MASTER',
'InstanceType': 'c1.medium',
'InstanceCount': 1,
'Configurations': [
{'Classification': 'yarn-site',
'Properties': {'yarn.nodemanager.vmem-check-enabled': 'false'}}]},
{'Name': 'core',
'InstanceRole': 'CORE',
'InstanceType': 'c1.medium',
'InstanceCount': 1,
'Configurations': [
{'Classification': 'yarn-site',
'Properties': {'yarn.nodemanager.vmem-check-enabled': 'false'}}]},
]},
Steps=[
{'Name': 'My word count example',
'HadoopJarStep': {
'Jar': 'command-runner.jar',
'Args': [
'hadoop-streaming',
'-files', 's3://mybucket/wordSplitter.py#wordSplitter.py',
'-mapper', 'python2.7 wordSplitter.py',
'-input', 's3://mybucket/input/',
'-output', 's3://mybucket/output/',
'-reducer', 'aggregate']}
}
],
JobFlowRole='EMR_EC2_DefaultRole',
ServiceRole='EMR_DefaultRole',
)
我不记得需要使用 boto 执行此操作,但在未禁用 vmem-check-enabled 的情况下正确运行简单流式作业时遇到了问题。
此外,如果您的脚本位于 S3 上的某个位置,请使用 -files 下载它(将 #filename 附加到参数后,使下载的文件在集群中以 filename 的形式可用)。