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. 利用FFmpeg转压视频的说明

    当我们制作视频的时候,录制完成的视频往往很大,很容易超过50M,上传的时候会很慢.下面将相关技巧说明如下(转载,版权属于原作者所有). 利用FFmpeg转压视频的说明 录制介绍视频时可以用尽可能高的分 ...

  2. wCF 问题收集页

    1.设置最大序列化集合元素个数 http://msdn.microsoft.com/zh-cn/library/system.runtime.serialization.datacontractser ...

  3. HDU1301&&POJ1251 Jungle Roads 2017-04-12 23:27 40人阅读 评论(0) 收藏

    Jungle Roads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25993   Accepted: 12181 De ...

  4. openfire搭建spackweb在线即时聊天

    1.首先去openFire官网下载openFire以及spackweb,以下地址可以2样东西一次打包下载.http://download.csdn.net/detail/a315157973/8048 ...

  5. Asp.NetCore Razor 模式 Web 应用

    Razor 页面是 ASP.NET Core MVC 的一个新功能,它可以使基于页面的编码方式更简单高效. Razor 页面是 ASP.NET Core 2.0 中的一个新选择,它是基于页面的编程模型 ...

  6. Python学习-9.Python函数定义

    先定义一个最基本的函数作为例子: def Print(msg): print(msg) 函数名为Print,参数有一个,为msg,函数体调用print系统函数,输出msg. 接下来就是可变参数,这个特 ...

  7. Postgres的TOAST技术

    一.介绍 首先,Toast是一个名字缩写,全写是The OverSized Attribute Storage Technique,即超尺寸字段存储技术,顾名思义,是说超长字段在Postgres的一个 ...

  8. centos下安装pip2

    # 背景 新机器,安装完python2后发现竟然不自带pip,按照我的理解现在新版本的python,不管是2还是3都会自带pip的.没办法,需要自己去安装pip的 # 步骤 1. 最开始查到的是通过y ...

  9. 手动编译安装LAMP之httpd

    安装前准备: 开发环境:Development Libraries 和 Development Tools httpd环境包:apr-1.4.6.tar.bz2 和 apr-util-1.4.1.ta ...

  10. Kafka与.net core(二)zookeeper

    1.zookeeper简单介绍 1.1作用 zookeeper的作用是存储kafka的服务器信息,topic信息,和cunsumer信息.如下图: 而zookeeper是个什么东西呢?简单来说就是一个 ...