我正在尝试从 mrjob 运行这个关于在 AWS EMR 上运行字数统计 MapReduce 作业的示例。
这是来自mrjob
的字数统计代码示例:
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: <my_key_id>
aws_secret_access_key: <my_access_key>
region: ap-southeast-1
subnet: subnet-9a2f90fc
ec2_key_pair: EMR
ec2_key_pair_file: ~/.ssh/EMR.pem
ssh_tunnel: true
运行命令:
python word_count.py -r emr --cluster-id=j-CLUSTER_ID readme.rst --conf-path mrjob.conf
我的问题是,如果我选择集群的应用程序为 Core Hadoop
,我可以运行此示例,但我无法使用 Spark
应用程序选项运行它。
这是使用 Spark EMR 集群运行时的错误:
Waiting for Step 1 of 1 (s-xxx) to complete...
PENDING (cluster is RUNNING: Running step)
FAILED
Cluster j-CLUSTER_ID is WAITING: Cluster ready after last step failed.
我想用 Spark
运行它,因为我的应用程序涉及一些 Spark 代码和一些 MapReduce 代码。
我该如何解决这个问题?