Working on hadoop, especially on test clusters, I have managed to break my HDFS layer and sometimes with no possible redemption, or at least none that I wanted to invest time in. For whatever other reason sometimes you just want to scratch your HDFS and start anew.

Without going on too much details, which is outside the point of this blog post. HDFS is mainly composed of 2 types of elements:

  • Namenode: At high level the namenode stores the HDFS namespace, think of it as your file system tree.
  • Datanode: this is where your data is actually stored

The Namenode: /hadoop/hdfs/namenode/current

All new edits are written to the the edit log and regularly merged out to an FSImage file, for more concise management. An fsimage file represents the file system state after all modifications up to a specific transaction ID.   The seen_txid file, has the last seen transaction.                                           VERSION: contains cluster and hdfs IDs.

For a  more detailled explanation: Hdfs metadata

The Datanode: /hadoop/hdfs/data/current

 In our example we will only focus on VERSIOn very close to the namenode VERSION.

Hdfs non HA formatting

In non HA everything is simple enough.

  1. Stop the HDFS Service
  2. run hadoop namenode -format​ (as user hdfs)
  3. clear the data directory on all datanodes
  4. restart hdfs

At this point your HDFS layer is empty and if you check the VERSION of namenodes and datanodes they should coincide

Hdfs HA formatting

In HA things get a little more complicated. In HA Standby and Active namenodes have a shared storage managed by the journal node service. HA relies on a failover scenario to swap from StandBy to Active Namenode and as any other system in hadoop this uses zookeeper. As you can see a couple more pieces need to made aware of a formatting action.

The initial steps are very close

  1. Stop the Hdfs service
  2. Start only the journal nodes (as they will need to be made aware of the formatting)
  3. On the first namenode (as user hdfs)
    1. hadoop namenode -format​
    2. hdfs namenode -initializeSharedEdits -force (for the journal nodes)
    3. hdfs zkfc -formatZK -force (to force zookeeper to reinitialise)​
    4. restart that first namenode
  4. On the second namenode
    1. hdfs namenode -bootstrapStandby -force ​(force synch with first namenode)
  5. On every datanode clear the data directory
  6. Restart the HDFS service

This was a very simple step by step guide to formatting. In a later article we will cover actually repairing common errors in HDFS

Formatting HDFS的更多相关文章

  1. HDFS中namenode启动失败

    1.环境配置: -1.core-site.xml文件 <configuration> <property> <name>fs.defaultFS</name& ...

  2. Hadoop 2.7.4 HDFS+YRAN HA部署

    实验环境 主机名称 IP地址 角色 统一安装目录 统一安装用户 sht-sgmhadoopnn-01 172.16.101.55 namenode,resourcemanager /usr/local ...

  3. Hadoop集群-HDFS集群中大数据运维常用的命令总结

    Hadoop集群-HDFS集群中大数据运维常用的命令总结 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客会简单涉及到滚动编辑,融合镜像文件,目录的空间配额等运维操作简介.话 ...

  4. Hadoop集群(二) HDFS搭建

    HDFS只是Hadoop最基本的一个服务,很多其他服务,都是基于HDFS展开的.所以部署一个HDFS集群,是很核心的一个动作,也是大数据平台的开始. 安装Hadoop集群,首先需要有Zookeeper ...

  5. Apache hadoop namenode ha和yarn ha ---HDFS高可用性

    HDFS高可用性Hadoop HDFS 的两大问题:NameNode单点:虽然有StandbyNameNode,但是冷备方案,达不到高可用--阶段性的合并edits和fsimage,以缩短集群启动的时 ...

  6. HDFS ha 格式化报错:a shared edits dir must not be specified if HA is not enabled.

    错误内容: Formatting using clusterid: CID-19921335-620f-4e72-a056-899702613a6b2019-01-12 07:28:46,986 IN ...

  7. hadoop 2.7.3本地环境运行官方wordcount-基于HDFS

    接上篇<hadoop 2.7.3本地环境运行官方wordcount>.继续在本地模式下测试,本次使用hdfs. 2 本地模式使用fs计数wodcount 上面是直接使用的是linux的文件 ...

  8. Hadoop学习之旅二:HDFS

    本文基于Hadoop1.X 概述 分布式文件系统主要用来解决如下几个问题: 读写大文件 加速运算 对于某些体积巨大的文件,比如其大小超过了计算机文件系统所能存放的最大限制或者是其大小甚至超过了计算机整 ...

  9. python基础操作以及hdfs操作

    目录 前言 基础操作 hdfs操作 总结 一.前言        作为一个全栈工程师,必须要熟练掌握各种语言...HelloWorld.最近就被"逼着"走向了python开发之路, ...

随机推荐

  1. idea中处理异常的快捷键

    alt+Enter

  2. Mac下eclipse 启动时出现An error has occurred. See the log file的问题

    eclipse原来可以使用的好好的,装了多个版本的jdk后,打开eclipse出现An error has occurred. See the log file的问题,经过查找,可能原因之一是机子装了 ...

  3. 使用js/jquery查找iframe中的

    原生js  一.在iframe的父窗口中获取iframe中的元素: js代码 格式: window.frames["iframe的name值"].document.getEleme ...

  4. myeclispe2014启动后报错 Subclipse talks to Subversion via a Java API that requires access to native libraries.

    解决方案: Window -> Preferences -> Team -> SVN, 将SVN接口的Client修改为如图所示

  5. ZOJ2256 Mincost 2017-04-16 19:36 44人阅读 评论(0) 收藏

    Mincost Time Limit: 2 Seconds      Memory Limit: 65536 KB The cost of taking a taxi in Hangzhou is n ...

  6. scala中Nil用法

    http://www.runoob.com/scala/scala-lists.html 即Nil是空List 双冒号是追加进入 package com.yjsj.spark object scala ...

  7. R12 更新对应用户的字符集

    R12 更新对应用户的字符集     症状:应用系统数据导出操作,经常发生导出文件(XLS / TSV)产生简体中文乱码. 方案:针对客户端当前用户进行字符集更新 ZHS16GBK,而不影响其他用户. ...

  8. 咏南中间件+开发框架支持最新的DELPHI 10.2 TOKYO

    咏南中间件+开发框架支持最新的DELPHI 10.2 TOKYO 价格十分优惠.有意者请向本人索取演示程序! 你只需花一套中间件的价格,就可获得:中间件,CS开发框架一套(赠送),BS开发框架一套(赠 ...

  9. [转载]MVC、MVP以及Model2(下)

    通过采用MVC模式,我们可以将可视化UI元素的呈现.UI处理逻辑和业务逻辑分别定义在View.Controller和Model中,但是对于三者之间的交互,MVC并没有进行严格的限制.最为典型的就是允许 ...

  10. 自定义TFS工作项“所有链接”列表中的列

    这个功能只有使用团队资源管理器查看工作项才有