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. 阿里云OSS-js分片上传

    使用 aliyun-oss-sdk-4.4.4.min.js 方式一 客户端授权 https://help.aliyun.com/document_detail/32069.html 通过new OS ...

  2. Oracle学习笔记(十二)

    十三.存储过程和存储函数1.掌握存储过程(相当于建立一个函数或者方法体,然后通过外部对其调用) 指存储在数据库中供所有程序调用的子程序叫做存储过程或存储函数. 相同点: 完成特定功能的程序 区别: 是 ...

  3. 测试用Word2007发布博客文章

    目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...

  4. util:properties

    示例 <util:properties id="db" location="classpath:db.properties" /> 全部属性 功能概 ...

  5. [label][转载][paypal]paypal在线支付接口的WEB语言设置

    http://stephen830.iteye.com/blog/274072 ★★★ 本篇为原创,需要引用转载的朋友请注明:< http://stephen830.iteye.com/blog ...

  6. EJB学习手记

    周末两天,看了两天的ejb知识.公司有个转发消息的程序,里面是根据ejb/jms+cdi/event做的,这些之前没接触过. 总而言之,从中学到了很多东西,从ejb到webservice. jboss ...

  7. 将引用了第三方jar包的Java项目打包成jar文件的两种方法

    方案一:用Eclipse自带的Export功能 步骤1:准备主清单文件 “MANIFEST.MF”, 由于是打包引用了第三方jar包的Java项目,故需要自定义配置文件MANIFEST.MF,在该项目 ...

  8. Android 多图,大图内存优化

    策略: 1. 图片压缩 如果所需尺寸大于图片原始尺寸,可以压缩图片节省内存. 2. 图片缓存 每个图片加载时都会生成一个 Bitmap.把这些 Bitmap 缓存起来以重用相同的图片,避免重复创建. ...

  9. Python3.5 学习四

    装饰器 定义:本质是函数,装饰其他函数,即为其他函数添加附加功能的 原则: 1 不能修改被装饰函数的源代码 2 不能改变被装饰函数的调用方式(对于被装饰函数来说完全透明,不会受影响) 实现装饰器功能的 ...

  10. FusionCharts的使用方法 - 公司所用的flash式的图像统计工具

    我们公司一直用这个图表统计, 最近整理了一下相关文档,提供大家学习. 首先可以看看 http://www.cnblogs.com/xuhongfei/archive/2013/04/12/301688 ...