【发布时间】:2015-04-19 07:42:40
【问题描述】:
我正在尝试使用 python MRJob 在 Amazon EC2 上运行一个实例 这是在 txt 文件中查找最常用单词的简单 python 脚本
from mrjob.job import MRJob
class MRWordFrequencyCount(MRJob):
def mapper(self, _, line):
yield "chars", len(line)
yield "words", len(line.split())
yield "lines", 1
def reducer(self, key, values):
yield key, sum(values)
if __name__ == '__main__':
MRWordFrequencyCount.run()
这是我的 mrjob.conf 文件:
runners:
emr:
aws_access_key_id: XXXXXXXXXXXXXXXXXX
aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
aws_region: us-west-1
ec2_key_pair: EMR
ec2_key_pair_file: ~/EMR.pem # ~/ and $ENV_VARS allowed here
ssh_tunnel_to_job_tracker: true
当我运行脚本时:
python MRMostUsedWord.py -r emr romeo.txt > most_used_word.out
我收到以下错误:
<Error>
<Type>Sender</Type>
<Code>ValidationError</Code>
<Message>InstanceProfile is required for creating cluster</Message>
</Error>
<RequestId>4d1a1e3b-e665-11e4-b9e1-a557982e1081</RequestId>
</ErrorResponse>
你知道我为什么会收到这个错误吗?
我也在使用以下命令创建实例配置文件:
aws emr create-default-roles
也许需要修改 mrjob.conf 文件?但我不知道怎么做?
【问题讨论】:
标签: python amazon-ec2 emr mrjob