不幸的是,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
在集群中)。