Formatting HDFS
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.
- Stop the HDFS Service
- run hadoop namenode -format (as user hdfs)
- clear the data directory on all datanodes
- 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
- Stop the Hdfs service
- Start only the journal nodes (as they will need to be made aware of the formatting)
- On the first namenode (as user hdfs)
- hadoop namenode -format
- hdfs namenode -initializeSharedEdits -force (for the journal nodes)
- hdfs zkfc -formatZK -force (to force zookeeper to reinitialise)
- restart that first namenode
- On the second namenode
- hdfs namenode -bootstrapStandby -force (force synch with first namenode)
- On every datanode clear the data directory
- 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的更多相关文章
- HDFS中namenode启动失败
1.环境配置: -1.core-site.xml文件 <configuration> <property> <name>fs.defaultFS</name& ...
- Hadoop 2.7.4 HDFS+YRAN HA部署
实验环境 主机名称 IP地址 角色 统一安装目录 统一安装用户 sht-sgmhadoopnn-01 172.16.101.55 namenode,resourcemanager /usr/local ...
- Hadoop集群-HDFS集群中大数据运维常用的命令总结
Hadoop集群-HDFS集群中大数据运维常用的命令总结 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客会简单涉及到滚动编辑,融合镜像文件,目录的空间配额等运维操作简介.话 ...
- Hadoop集群(二) HDFS搭建
HDFS只是Hadoop最基本的一个服务,很多其他服务,都是基于HDFS展开的.所以部署一个HDFS集群,是很核心的一个动作,也是大数据平台的开始. 安装Hadoop集群,首先需要有Zookeeper ...
- Apache hadoop namenode ha和yarn ha ---HDFS高可用性
HDFS高可用性Hadoop HDFS 的两大问题:NameNode单点:虽然有StandbyNameNode,但是冷备方案,达不到高可用--阶段性的合并edits和fsimage,以缩短集群启动的时 ...
- 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 ...
- hadoop 2.7.3本地环境运行官方wordcount-基于HDFS
接上篇<hadoop 2.7.3本地环境运行官方wordcount>.继续在本地模式下测试,本次使用hdfs. 2 本地模式使用fs计数wodcount 上面是直接使用的是linux的文件 ...
- Hadoop学习之旅二:HDFS
本文基于Hadoop1.X 概述 分布式文件系统主要用来解决如下几个问题: 读写大文件 加速运算 对于某些体积巨大的文件,比如其大小超过了计算机文件系统所能存放的最大限制或者是其大小甚至超过了计算机整 ...
- python基础操作以及hdfs操作
目录 前言 基础操作 hdfs操作 总结 一.前言 作为一个全栈工程师,必须要熟练掌握各种语言...HelloWorld.最近就被"逼着"走向了python开发之路, ...
随机推荐
- WebClient使用与IIS7最大上传文件--升级&引导窗口&目录同步完整解决方法
IIS7最大上传文件说明:http://www.mzwu.com/article.asp?id=2449 WebClient使用说明使用using 及时回收资源 using(var wc=new W ...
- C++笔记16之const的用法总结
const主要是为了程序的健壮型,减少程序出错. 最基本的用法: const int a=100; b的内容不变,b只能是100也就是声明一个int类型的常量(#define b =100) int ...
- uva 10169 - Urn-ball Probabilities !(概率)
题目链接:uva 10169 - Urn-ball Probabilities ! 题目大意:在一个箱子中,原本有1个红球,然后任意取出(有放回)一个球,然后再往里放一个白球(每次取都要放进一个白球) ...
- ZOJ3708:Density of Power Network
The vast power system is the most complicated man-made system and the greatest engineering innovatio ...
- [label][Google-Developers] Your First Multi Screen Site
内容是任何网站最重要的部分. 所以,让我们为内容而设计,而不要让设计支配内容. 1. 首先确定我们需要的内容: 2. 基于这个内容,为无论宽.窄的 viewport 创建一个页面结构: 3. 然后在简 ...
- 我的第一个博客&GuiHub简单练习
个人介绍 姓名:马瑞 性别:男 班级:网络工程143 出生年月:1995.11 兴趣爱好:玩玩电脑,看看动漫. 编程能力:完全是菜鸟. GutHub的使用体验: 第一步:注册github,这很简 ...
- kv数据库对比总结
集群型: hbase Cassandra scylladb redis类: redis + twemproxy codis 持久型: pika ssdb
- linux free命令下 cached占用很大
# 背景 使用free -h命令,展示如下: # 解决方法 先执行sync命令,同步数据 然后执行 echo 1 > /proc/sys/vm/drop_caches echo 2 > / ...
- shell脚本参数中有空格
shell脚本参数中有空格 在shell脚本中如果有空格的处理如下: sh test.sh "hello word" echo $1 得到的是hello,而不是hello word ...
- VUE 学习笔记 三 模板语法
1.插值 a.文本 数据绑定最常见的形式就是使用“Mustache”语法 (双大括号) 的文本插值 <span>Message: {{ msg }}</span> v-once ...