首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

运用Hadoop har归档历史文件(小文件)

2012-06-26 
使用Hadoop har归档历史文件(小文件)应用场景我们的hdfs中保存大量小文件(当然不产生小文件是最佳实践),这

使用Hadoop har归档历史文件(小文件)
应用场景

我们的hdfs中保存大量小文件(当然不产生小文件是最佳实践),这样会把namenode的namespace搞的很大。namespace保存着hdfs文件的inode信息,文件越多需要的namenode内存越大,但内存毕竟是有限的(这个是目前hadoop的硬伤)。

下面图片展示了,har文档的结构。har文件是通过mapreduce生成的,job结束后源文件不会删除。

?
运用Hadoop har归档历史文件(小文件)

?har命令说明
    ? 参数“-p”为src path的前缀? src可以写多个path

?

public static void main(String[] args) throws Exception {Configuration conf = new Configuration();conf.set("fs.default.name", "hdfs://xxx.xxx.xxx.xxx:9000");HarFileSystem fs = new HarFileSystem();fs.initialize(new URI("har:///user/heipark/20120108_15.har"), conf);FileStatus[] listStatus = fs.listStatus(new Path("sub_dir"));for (FileStatus fileStatus : listStatus) {System.out.println(fileStatus.getPath().toString());}}

?

?

参考文章:

http://denqiang.com/?m=20111114

http://c.hocobo.net/2010/08/05/har/

?

?

-- heipark

?

?

?

?

?

热点排行