在 Hadoop 中将多个文件合并为一个 [英] Merging multiple files into one within Hadoop

查看:59
本文介绍了在 Hadoop 中将多个文件合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将多个小文件放入我的输入目录,我想在不使用本地文件系统或编写 mapred 的情况下将它们合并为一个文件.有没有办法使用 hadoof fs 命令或 Pig 来做到这一点?

I get multiple small files into my input directory which I want to merge into a single file without using the local file system or writing mapreds. Is there a way I could do it using hadoof fs commands or Pig?

谢谢!

推荐答案

为了保持网格上的所有内容,使用 hadoop 流,并使用单个减速器和 cat 作为映射器和减速器(基本上是一个 noop) - 使用 MR 标志添加压缩.

In order to keep everything on the grid use hadoop streaming with a single reducer and cat as the mapper and reducer (basically a noop) - add compression using MR flags.

hadoop jar \
    $HADOOP_PREFIX/share/hadoop/tools/lib/hadoop-streaming.jar \<br>
    -Dmapred.reduce.tasks=1 \
    -Dmapred.job.queue.name=$QUEUE \
    -input "$INPUT" \
    -output "$OUTPUT" \
    -mapper cat \
    -reducer cat

如果你想压缩添加
-Dmapred.output.compress=true \-Dmapred.output.compression.codec=org.apache.hadoop.io.compress.GzipCodec

If you want compression add
-Dmapred.output.compress=true \ -Dmapred.output.compression.codec=org.apache.hadoop.io.compress.GzipCodec

这篇关于在 Hadoop 中将多个文件合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆