关于Hadoop

时间:2017-04-01 09:32:38

标签: hadoop hdfs

我读到了Hadoop的HDFS,并了解到hadoop旨在处理较小数量的较大尺寸文件,而不是大量小尺寸文件。

这样做的原因是,如果有大量的小型文件,那么Namenode's内存很快就会被丢弃。我很难理解这个论点。

考虑以下情况:

1000个小文件,每个文件大小为128 MB(hdfs块的块大小相同)。

因此,这意味着Namenode的内存中存有1000个条目,并保存此信息。

现在,请考虑以下情况:

一个BIG文件,块大小为128 MB * 1000。

现在不知道Namenode有这个BIG单个文件的1000个条目吗?

这个结论是否正确,在这两种情况下,Namenode在内存中有关于文件块信息的相同数量的条目?如果是这样,那么为什么hadoop对少量较大尺寸的文件而不是大量小尺寸文件有效呢?

任何人都可以帮助理解这个吗?

1 个答案:

答案 0 :(得分:1)

  

HDFS中的每个文件,目录和块都表示为对象   namenode的内存,每个内存占用 ~150字节

案例1:

Number of Files = 1000
Number of Blocks per file = 1
Total Number of Blocks = 1000 (Number of Files * Number of Blocks per file)
Total number of objects in Namenode's namespace = 2000 (Number of Files + Total Number of Blocks)
Total Namenode Memory Used = 2000 * 150 bytes

案例2:

Number of Files = 1
Number of Blocks per file = 1000
Total Number of Blocks = 1000 (Number of Files * Number of Blocks per file)
Total number of objects in Namenode's namespace = 1001 (Number of Files + Total Number of Blocks)
Total Namenode Memory Used = 1001 * 150 bytes

在这两种情况下,数据占用的总大小保持不变。但在第一种情况下,使用了 300KB 的namenode内存,而在第二种情况下只使用了 150.15KB

相关问题