Pythonを使用してHadoopストリーミングを試してみています。ここから助けを借りて、簡単なマップを作成し、スクリプトを削減しました
map
スクリプトは次のとおりです。
#!/usr/bin/env python
import sys, urllib, re
title_re = re.compile("<title>(.*?)</title>", re.MULTILINE | re.DOTALL | re.IGNORECASE)
for line in sys.stdin:
url = line.strip()
match = title_re.search(urllib.urlopen(url).read())
if match :
print url, "\t", match.group(1).strip()
スクリプトは次のreduce
とおりです。
#!/usr/bin/env python
from operator import itemgetter
import sys
for line in sys.stdin :
line = line.strip()
print line
これらのスクリプトをhadoopストリーミングjarを使用して実行すると、map
タスクが終了し、100%完了しているのに、reduce
ジョブが22%でスタックし、長期間経過するとERROR streaming.StreamJob: Job not successful. Error: # of failed Map Tasks exceeded allowed limit. FailedCount: 1.
エラーが発生することがわかります。
この背後にある正確な理由を見つけることができません。
私のターミナルウィンドウは次のようになります:
shekhar@ubuntu:/host/Shekhar/Softwares/hadoop-1.0.0$ hadoop jar contrib/streaming/hadoop-streaming-1.0.0.jar -mapper /host/Shekhar/HadoopWorld/MultiFetch.py -reducer /host/Shekhar/HadoopWorld/reducer.py -input /host/Shekhar/HadoopWorld/urls/* -output /host/Shekhar/HadoopWorld/titles3
Warning: $HADOOP_HOME is deprecated.
packageJobJar: [/tmp/hadoop-shekhar/hadoop-unjar2709939812732871143/] [] /tmp/streamjob1176812134999992997.jar tmpDir=null
12/05/27 11:27:46 INFO util.NativeCodeLoader: Loaded the native-hadoop library
12/05/27 11:27:46 INFO mapred.FileInputFormat: Total input paths to process : 3
12/05/27 11:27:46 INFO streaming.StreamJob: getLocalDirs(): [/tmp/hadoop-shekhar/mapred/local]
12/05/27 11:27:46 INFO streaming.StreamJob: Running job: job_201205271050_0006
12/05/27 11:27:46 INFO streaming.StreamJob: To kill this job, run:
12/05/27 11:27:46 INFO streaming.StreamJob: /host/Shekhar/Softwares/hadoop-1.0.0/libexec/../bin/hadoop job -Dmapred.job.tracker=localhost:9001 -kill job_201205271050_0006
12/05/27 11:27:46 INFO streaming.StreamJob: Tracking URL: http://localhost:50030/jobdetails.jsp?jobid=job_201205271050_0006
12/05/27 11:27:47 INFO streaming.StreamJob: map 0% reduce 0%
12/05/27 11:28:07 INFO streaming.StreamJob: map 67% reduce 0%
12/05/27 11:28:37 INFO streaming.StreamJob: map 100% reduce 0%
12/05/27 11:28:40 INFO streaming.StreamJob: map 100% reduce 11%
12/05/27 11:28:49 INFO streaming.StreamJob: map 100% reduce 22%
12/05/27 11:31:35 INFO streaming.StreamJob: map 67% reduce 22%
12/05/27 11:31:44 INFO streaming.StreamJob: map 100% reduce 22%
12/05/27 11:34:52 INFO streaming.StreamJob: map 67% reduce 22%
12/05/27 11:35:01 INFO streaming.StreamJob: map 100% reduce 22%
12/05/27 11:38:11 INFO streaming.StreamJob: map 67% reduce 22%
12/05/27 11:38:20 INFO streaming.StreamJob: map 100% reduce 22%
12/05/27 11:41:29 INFO streaming.StreamJob: map 67% reduce 22%
12/05/27 11:41:35 INFO streaming.StreamJob: map 100% reduce 100%
12/05/27 11:41:35 INFO streaming.StreamJob: To kill this job, run:
12/05/27 11:41:35 INFO streaming.StreamJob: /host/Shekhar/Softwares/hadoop-1.0.0/libexec/../bin/hadoop job -Dmapred.job.tracker=localhost:9001 -kill job_201205271050_0006
12/05/27 11:41:35 INFO streaming.StreamJob: Tracking URL: http://localhost:50030/jobdetails.jsp?jobid=job_201205271050_0006
12/05/27 11:41:35 ERROR streaming.StreamJob: Job not successful. Error: # of failed Map Tasks exceeded allowed limit. FailedCount: 1. LastFailedTask: task_201205271050_0006_m_000001
12/05/27 11:41:35 INFO streaming.StreamJob: killJob...
Streaming Job Failed!
誰か助けてくれませんか?
EDIT ジョブトラッカーの詳細は次のとおりです。
Hadoop job_201205271050_0006 on localhost
User: shekhar
Job Name: streamjob1176812134999992997.jar
Job File: file:/tmp/hadoop-shekhar/mapred/staging/shekhar/.staging/job_201205271050_0006/job.xml
Submit Host: ubuntu
Submit Host Address: 127.0.1.1
Job-ACLs: All users are allowed
Job Setup: Successful
Status: Failed
Failure Info:# of failed Map Tasks exceeded allowed limit. FailedCount: 1. LastFailedTask: task_201205271050_0006_m_000001
Started at: Sun May 27 11:27:46 IST 2012
Failed at: Sun May 27 11:41:35 IST 2012
Failed in: 13mins, 48sec
Job Cleanup: Successful
Black-listed TaskTrackers: 1
Kind % Complete Num Tasks Pending Running Complete Killed Failed/Killed
Task Attempts
map 100.00%
3 0 0 2 1 4 / 0
reduce 100.00%
1 0 0 0 1 0 / 1