hadoop - 合并 HDFS 上的压缩文件

标签 hadoop compression apache-pig hdfs

如何将 HDFS 目录中的所有文件合并到一个压缩文件中, 无需通过本地计算机复制数据?例如,但不一定,使用 Pig?

例如,我有一个文件夹/data/input,其中包含文件 part-m-00000.gz 和 part-m-00001.gz。现在我想将它们合并成一个文件/data/output/foo.gz

最佳答案

我建议查看 FileCrush ( https://github.com/edwardcapriolo/filecrush ),这是一种使用 MapReduce 合并 HDFS 上文件的工具。它完全按照您的描述进行操作,并提供了多个选项来处理压缩和控制输出文件的数量。

  Crush --max-file-blocks XXX /data/input /data/output

max-file-blocks 表示每个输出文件的最大 dfs block 数。例如,根据文档:

With the default value 8, 80 small files, each being 1/10th of a dfs block will be grouped into to a single output file since 8 * 1/10 = 8 dfs blocks. If there are 81 small files, each being 1/10th of a dfs block, two output files will be created. One output file contain the combined contents of 41 files and the second will contain the combined contents of the other 40. A directory of many small files will be converted into fewer number of larger files where each output file is roughly the same size.

关于hadoop - 合并 HDFS 上的压缩文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30078945/

相关文章:

algorithm - Terra 压缩是否可行?如果是,请解释并提供 sample

apache-pig - 如何在 Pig 中指定任务超时?

Apache Falcon 无法提交集群定义

hadoop - Hadoop排序示例失败,出现 'not a SequenceFile'。如何设置SequenceFile

hadoop - 监控 HBase 集群

hadoop - pig 负载 : deprecated property fs. default.name

apache-pig - 如何循环 Bag, Pig 中的元组

java - Mapreduce 字数统计 Hadoop 最高频词

c# - 以二进制表示形式获取字符串、整数等?

c - C 语言无损数据压缩,无需动态内存分配