6

我正在学习蜂巢。我已经设置了一个名为records. 架构如下:

year        : string
temperature : int
quality     : int

这是示例行

1999 28 3
2000 28 3
2001 30 2

现在,我完全按照 Hadoop The Definitive Guide 一书中的说明在 python 中编写了一个示例 map reduce 脚本:

import re
import sys

for line in sys.stdin:
    (year,tmp,q) = line.strip().split()
    if (tmp != '9999' and re.match("[01459]",q)):
        print "%s\t%s" % (year,tmp)

我使用以下命令运行它:

ADD FILE /usr/local/hadoop/programs/sample_mapreduce.py;
SELECT TRANSFORM(year, temperature, quality)
USING 'sample_mapreduce.py'
AS year,temperature;

执行失败。在终端上我得到这个:

Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
2012-08-23 18:30:28,506 Stage-1 map = 0%,  reduce = 0%
2012-08-23 18:30:59,647 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201208231754_0005 with errors
Error during job, obtaining debugging information...
Examining task ID: task_201208231754_0005_m_000002 (and more) from job job_201208231754_0005
Exception in thread "Thread-103" java.lang.RuntimeException: Error while reading from task log url
    at org.apache.hadoop.hive.ql.exec.errors.TaskLogProcessor.getErrors(TaskLogProcessor.java:130)
    at org.apache.hadoop.hive.ql.exec.JobDebugger.showJobFailDebugInfo(JobDebugger.java:211)
    at org.apache.hadoop.hive.ql.exec.JobDebugger.run(JobDebugger.java:81)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: http://master:50060/tasklog?taskid=attempt_201208231754_0005_m_000000_2&start=-8193
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
    at java.net.URL.openStream(URL.java:1010)
    at org.apache.hadoop.hive.ql.exec.errors.TaskLogProcessor.getErrors(TaskLogProcessor.java:120)
    ... 3 more

我转到失败的作业列表,这是堆栈跟踪

java.lang.RuntimeException: Hive Runtime Error while closing operators
    at org.apache.hadoop.hive.ql.exec.ExecMapper.close(ExecMapper.java:226)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:57)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:436)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
    at org.apache.hadoop.mapred.Child.main(Child.java:249)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hit error while closing ..
    at org.apache.hadoop.hive.ql.exec.ScriptOperator.close(ScriptOperator.java:452)
    at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:566)
    at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:566)
    at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:566)
    at org.apache.hadoop.hive.ql.exec.ExecMapper.close(ExecMapper.java:193)
    ... 8 more

相同的轨迹重复了 3 次以上。

请问,有人可以帮我解决这个问题吗?这里有什么问题?我完全按照书本行事。似乎是什么问题。似乎有两个错误。在终端上,它说它无法从任务日志 url 中读取。在失败的作业列表中,异常说明了一些不同的内容。请帮忙

4

2 回答 2

2

我从 hadoop 管理界面转到 stedrr 日志,发现 python 存在语法错误。然后我发现当我创建配置单元表时,字段分隔符是制表符。而在split()我没有提到的。所以我把它改成split('\t')它工作正常!

于 2012-08-24T07:44:35.757 回答
0

只需使用“describe formatted”,在输出底部附近,您会发现“Storage Desc Params:”,它描述了所使用的任何分隔符。

于 2013-07-27T01:28:46.310 回答