2014-09-30 99 views
1

据我所知,在主节点我们有名称节点,它维护两个文件中的元数据。一个是FSImage,另一个是编辑日志。
因此,这个FSImage在hadoop系统启动时初始加载,并且此FSImage包含存储的簇和数据的目录结构。然后,对于每个发生的事务,编辑日志文件都会更新。Hadoop - HDFS Namenode元数据 - FSImage

我的问题有以下几点:

  1. 这些是只包含的所有信息(的FsImage和EditLogs)还是有更多的文件?
  2. 这是否意味着FSImage文件只会被写入一次?
  3. 如果是,那么它为什么总是被复制到辅助名称节点?它不是在增加一项任务来完成吗?
  4. 假设我在hdfs中添加或删除了一个新文件;那么这个FSImage会不会被更新?
+0

我觉得这本身http://stackoverflow.com/questions/24288942/hadoop-namenode-metadata-fsimage-and-edit-logs回答几个你的问题。 – blackSmith 2014-09-30 13:53:49

回答

0
1) Yes only these two files are there . 

    2) This is true for name node . 

    3) It is copied to secondary name node for persistent storage , things would work fine un till name node is up ,lets say you have done so many changes like creating directories ,files ,putting the data to hdfs and so on so during run time this information is directly loaded into the memory but what if namenode goes down so what ever new meta information was there which is not embedded current fsimage ,it would get lost permanently because when ever your system would come up it would load the fsimage into memory since its the old fsimage it won't have new changes . With this secondary name node we are preserving this changes in edit.log and finally edit.log file used for fsimage and new fsimage can be replaced with old one . 
    4) process is when ever meta data gets changes ,this event gets written in edit.log file and after some specified interval these logs copied to secondary name node when their size gets too big then edit.log information is flushed into the form of fsimage. 
current fsimage would not get updated with addition or deletion of file ,these changes will directly cater in memory. 
2

要理解这一点,我们必须要经过它的细节,一步一个脚印,当Hadoop是加载的FsImage运行后

  1. 名称节点已经在数据的整个快照存储在内存中。

  2. 交易即将到来,信息存储在编辑日志中。

  3. 定期地,每隔默认值每隔一小时,检查点节点/辅助名称节点检索日志,并将它们与最新的fsimage合并并将数据保存为检查点。 此时,nn在内存中有图像,编辑日志被清空,最新检查点作为图像存储在snn/cn上。

回答你的问题。

  1. 是的,只有两个文件

  2. 在SNN/CN的的FsImage将定期更新。当导入检查点时,NN上的fsimage将被更新。这应该至少在重新启动时发生。

  3. 将editlog合并到fsimage是一个代价高昂的操作。它需要在namenode中进入安全模式才能合并数据。这不是在这样的环境可能

  4. 删除的日志以及一个写操作,因此它被保存在编辑日志

0
  1. 是的,这些是仅有的两个文件包含群集文件系统信息

  2. 在名称节点的每次重新启动时,FSImage将写入磁盘,并且在每个检查点上,SNN会将FSImage写入磁盘。在繁忙的群集上,EditLog将快速增长。如果编辑日志非常大,那么下次重新启动NN需要更长的时间。 SNN会定期合并EDITlog和FSImage。如果您的NN磁盘发生故障,SNN也将作为FSImage的备份。

  3. 是的。 FSImage将在主内存中更新,不在磁盘中。当时的Editlog将在磁盘上更新与新的交易