您的位置:首页 > 大数据 > Hadoop

HDFS块检查命令Fsck机理的相关分析

2016-05-09 10:53 387 查看
http://www.2cto.com/kf/201603/496108.html
在HDFS中,所有的文件都是以block块的概念而存在的,那么在这样海量的文件数据的情况下,难免会发生一些文件块损坏的现象,那么有什么好的办法去发现呢.答案是使用HDFS的fsck相关的命令.这个命令独立于dfsadmin的命令,可能会让部分人不知道HDFS中还存在这样的命令,本文就来深度挖掘一下这个命令的特殊的用处和内在机理的实现.

Fsck命令

其实说到fsck命令本身,熟悉Linux操作系统的人,可能或多或少听到过或使用过这个命令.Fsck命令的全称为file system check,更加类似的是一种修复命令.当然,本文不会讲大量的关于操作系统的fsck怎么用,而是HDFS下的fsck的使用,在bin/hdfs fsck下还是有很多可选参数的.

Fsck参数使用

本人在测试集群中输入hdfs fsck命令,获取了帮助信息,在此信息中展示了最全的参数使用说明:
$ hdfs fsck
Usage: hdfs fsck[-list-corruptfileblocks | [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]]start checking from this path
-move   move corrupted files to /lost+found
-delete delete corrupted files
-files  print out files being checked
-openforwrite   print out files opened for write
-includeSnapshots   include snapshot data if the given path indicates a snapshottable directory or there are snapshottable directories under it
-list-corruptfileblocks print out list of missing blocks and files they belong to
-blocks print out block report
-locations  print out locations for every block
-racks  print out network topology for data-node locations
-storagepolicies    print out storage policy summary for the blocks

-blockId    print out which file this blockId belongs to, locations (nodes, racks) of this block, and other diagnostics info (under replicated, corrupted or not, etc)

简单的总结一下,首先是必填参数和命令名:
bin/hdfs fsck
然后是一堆的可选参数:-move: 移动损坏的文件到/lost+found目录下 -delete: 删除损坏的文件 -files: 输出正在被检测的文件 -openforwrite: 输出检测中的正在被写的文件 -includeSnapshots: 检测的文件包括系统snapShot快照目录下的 -list-corruptfileblocks: 输出损坏的块及其所属的文件 -blocks: 输出block的详细报告 -locations: 输出block的位置信息 -racks: 输出block的网络拓扑结构信息 -storagepolicies: 输出block的存储策略信息 -blockId: 输出指定blockId所属块的状况,位置等信息具体参数功能对应到相应的程序会在下文的分析中进行详细的阐述.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hdfs fsck