【问题标题】:Hadoop Streaming "comparator.options" not being respectedHadoop Streaming“comparator.options”没有得到尊重
【发布时间】:2013-12-27 14:18:52
【问题描述】:

我有一个 python 映射器和减速器,我正在使用它和 Hadoop 流 API。 在命令行上,这些脚本可以正常工作并执行预期的工作。

我有一个示例 NASA Web 访问日志,您可以在此处看到它已正确处理和排序。

tail -n 10 NASA_access_log_Jul95  | ./mapper.py | sort | ./reducer.py | sort -r -k1,1
4   163.205.53.14
1   tornado.umd.edu

在 map reduce 作业中尝试相同的操作时,排序未得到尊重。

hadoop jar /usr/lib/hadoop-0.20-mapreduce/contrib/streaming/hadoop-streaming-2.0.0-mr1-cdh4.4.0.jar 
-D mapred.output.key.comparator.class=org.apache.hadoop.mapred.lib.KeyFieldBasedComparator     
-D mapred.text.key.comparator.options=-rk1,1
-file mapper.py -mapper mapper.py 
-file reducer.py -reducer reducer.py 
-input /user/cloudera/logcount/input 
-output /user/cloudera/logcount/output

具体参数: ma​​pred.text.key.comarator.options=-rk1,1

作业的最终结果是:

 hadoop fs -cat /user/cloudera/logcount/output/part-00000 | more
 16 ***.novo.dk
 32735  /
 161    /"
 1  /%20%20history/apollo/apollo-13/apollo-13.html
 4  /%20history/apollo/apollo-13/apollo-13.html

其中的值已排序,而不是我想要的键。 我也尝试过删除“r”,但没有效果。

如果不清楚,我会尝试按点击次数/观看次数(第一列)降序对结果进行排序。

感谢任何帮助! TIA。

【问题讨论】:

    标签: python hadoop mapreduce streaming bigdata


    【解决方案1】:

    您正在尝试对 reducer 而不是 mapper 的输出进行排序。请注意,排序阶段发生在 map 和 reduce 之间,这意味着 mapred.text.key.comparator.options 用于对 mapper 的输出进行排序。所以我猜你有两个选择:

    1. 重写mapper和reducer,将reducer的工作整合到mapper中,在reducer中什么都不做。
    2. 在此之后创建另一个 mapreduce 作业,用于按计数对输出进行排序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-02
      • 1970-01-01
      • 1970-01-01
      • 2013-12-16
      • 1970-01-01
      • 2017-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多