namenode HA配置:FsImage和edits log

栏目: 服务器 · 发布时间: 6年前

内容简介:The metadata in Hadoop NN consists of:If you list all files inside your NN workspace directory, you’ll see files include:When NN starts, Hadoop will load fsimage and apply all edit logs, and meanwhile do a lot of consistency checks, it’ll abort if the che

The metadata in Hadoop NN consists of:

  • fsimage: contains the complete state of the file system at a point in time
  • edit logs: contains each file system change (file creation/deletion/modification) that was made after the most recent fsimage.

If you list all files inside your NN workspace directory, you’ll see files include:

fsimage_0000000000000000000 (fsimage) fsimage_0000000000000000000.md5 edits_0000000000000003414-0000000000000003451 (edit logs, there’re many ones with different name) seen_txid (a separated file contains last seen transaction id)

When NN starts, Hadoop will load fsimage and apply all edit logs, and meanwhile do a lot of consistency checks, it’ll abort if the check failed. Let’s make it happen, I’ll rm edits_0000000000000000001-0000000000000000002 from many of my edit logs in my NN workspace, and then try to sbin/start-dfs.sh, I’ll get error message in log like:

java.io.IOException: There appears to be a gap in the edit log. We expected txid 1, but got txid 3.

So your error message indicates that your edit logs is inconsitent(may be corrupted or maybe some of them are missing). If you just want to play hadoop on your local and don’t care its data, you could simply hadoop namenode -format to re-format it and start from beginning, otherwise you need to recovery your edit logs, from SNN or somewhere you backed up before.

通常在HA配置时,需要先启动journalnode,之后运行:

hdfs namenode -initializeSharedEdits

来把namenode的edits log同步到各个journalnode节点上,journalnode只负责存储edits log,不存FsImage。 经过我的操作并观察发现,这个同步不一定能跟namenode完全一致,不明白这程序同步的依据是什么,同步之后journalnode和namenode的edits_inprogress会不一样,不过也不用担心,也不需要额外操作,过一会儿edits_inprogress就会一致了。 还有一点要说,经过hdfs namenode -initializeSharedEdits命令同步的edits log只是最近的一部分,如果集群之前是非HA的运行过一段时间的,edits log会有很多也许有几千个,那么它只会同步最近一段时间的一部分edits log。

暂时先这些。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Android群英传

Android群英传

徐宜生 / 电子工业出版社 / 2015-9 / 69.00元

《Android群英传》对具有一定Android开发基础的读者,以通俗易懂的语言介绍了Android开发的进阶技巧。《Android群英传》共分为13章,讲解了Android体系与系统架构、Android开发工具新接触、Android控件架构与自定义控件详解、ListView使用技巧、Android Scroll分析、Android绘图机制与处理技巧、Android动画机制与使用技巧、Activi......一起来看看 《Android群英传》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具