2017-12-03 6 views
0

주어진 입력 파일에서 소수의 평균 합계를 계산하는 Apache Hadoop에서 mapreduce 프로그램을 실행하려고합니다. 이 내 매퍼Hadoop Streaming에서 Python mapreduce를 실행하는 방법

import sys 
for word in sys.stdin: 
    print(word) 

입니다 그리고 난 다음 명령을 실행할 때, 지금 감속기

import sys 
primes = [] 
for word in sys.stdin: 
    if(int(word) >= 2): 
     isPrime = True 
     for a in range(2,int(word)): 
      if(int(word) % a == 0): 
       isPrime=False 
     if isPrime: 
      primes.append(int(word)) 
print(sum(primes)/float(len(primes))) 

이다 : 나는 오류를 얻을

python primesMapper.py primesReducer.py -r hadoop --hadoop-streaming-jar /opt/cloudera/parcels/CDH-5.10.0-1.cdh5.10.0.p0.41/lib/hadoop-mapreduce/hadoop-streaming-2.6.0-cdh5.10.0.jar hdfs://bigdata1.sis.uta.fi:/user/students/input/primes1.txt --output-dir group25/primes.txt 

, 아무것도하지만, 실제로 일어난다. 그냥 명령에 붙어 있습니다. 수동으로 종료하면 Mapper 파일에 고정되어 있습니다.

File "primesMapper.py", line 8, in <module> 
    for line in sys.stdin: 

도움이 필요하십니까?

+0

사용하여 실행을 시도 할 수 있습니다. '-r hadoop - 하둡 - 스트리밍 - 병 ' –

+0

http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/ –

답변

0

당신은 내가 전에이 구문을 본 적이

hadoop jar *jar_path* -file *mapper_path* -mapper "python primesMapper.py" -file *reducer_path* -reducer "python primesReducer.py" -input *input_path* -output *output_path*