来自:http://centoshowtos.org/hadoop/fix-corrupt-blocks-on-hdfs/

How do I know if my hadoop hdfs filesystem has corrupt blocks, and how do I fix it?

The easiest way to determine this is to run an fsck on the filesystem. If you have setup your hadoop environment variables you should be able to use a path of /, if not hdfs://ip.or.hostname:50070/.

hdfs fsck /

or.

hdfs fsck hdfs://ip.or.hostname:50070/

If the end of your output looks something like this, you have corrupt blocks on your fs.

.............................Status: CORRUPT Total size: 3453345169348 B (Total open files size: 664 B) Total dirs: 15233 Total files: 14029 Total symlinks: 0 (Files currently being written: 8) Total blocks (validated): 40961 (avg. block size 84308126 B) (Total open file blocks (not validated): 8)******************************** CORRUPT FILES: 2 MISSING BLOCKS: 2 MISSING SIZE: 15731297 B CORRUPT BLOCKS: 2 ******************************** Corrupt blocks: 2 Number of data-nodes: 12 Number of racks: 2FSCK ended at Fri Mar 27 XX:03:21 UTC 201X in XXX milliseconds

The filesystem under path '/' is CORRUPT

How do I know which files have blocks that are corrupt?

The output of the fsck above will be very verbose, but it will mention which blocks are corrupt. We can do some grepping of the fsck above so that we aren't "reading through a firehose".

hdfs fsck / | egrep -v '^\.+$' | grep -v replica | grep -v Replica

or

hdfs fsck hdfs://ip.or.host:50070/ | egrep -v '^\.+$' | grep -v replica | grep -v Replica

This will list the affected files, and the output will not be a bunch of dots, and also files that might currently have under-replicated blocks (which isn't necessarily an issue). The output should include something like this with all your affected files.

/path/to/filename.fileextension: CORRUPT blockpool BP-1016133662-10.29.100.41-1415825958975 block blk_1073904305

/path/to/filename.fileextension: MISSING 1 blocks of total size 15620361 B

The next step would be to determine the importance of the file, can it just be removed and copied back into place, or is there sensitive data that needs to be regenerated?

If it's easy enough just to replace the file, that's the route I would take.

Remove the corrupted file from your hadoop cluster

This command will move the corrupted file to the trash.

hdfs dfs -rm /path/to/filename.fileextension
hdfs dfs -rm hdfs://ip.or.hostname.of.namenode:50070/path/to/filename.fileextension

Or you can skip the trash to permanently delete (which is probably what you want to do)

hdfs dfs -rm -skipTrash /path/to/filename.fileextension
hdfs dfs -rm -skipTrash hdfs://ip.or.hostname.of.namenode:50070/path/to/filename.fileextension

How would I repair a corrupted file if it was not easy to replace?

This might or might not be possible, but the first step would be to gather information on the file's location, and blocks.

hdfs fsck /path/to/filename/fileextension -locations -blocks -files
hdfs fsck hdfs://ip.or.hostname.of.namenode:50070/path/to/filename/fileextension -locations -blocks -files

From this data, you can track down the node where the corruption is. On those nodes, you can look through logs and determine what the issue is. If a disk was replaced, i/o errors on the server, etc. If possible to recover on that machine and get the partition with the blocks online that would report back to hadoop and the file would be healthy again. If that isn't possible, you will unforunately have to find another way to regenerate.

转载于:https://www.cnblogs.com/sunxucool/p/5497820.html

Fix Corrupt Blocks on HDFS相关推荐

  1. How to fix corrupt HDFS FIles

    1 问题描述 HDFS在机器断电或意外崩溃的情况下,有可能出现正在写的数据(例如保存在DataNode内存的数据等)丢失的问题.再次重启HDFS后,发现hdfs无法启动,查看日志后发现,一直处于安全模 ...

  2. ORA-19566 exceeded limit of 0 corrupt blocks数据坏块处理

    问题描述 RMAN备份失败,报错如下: channel ch1: starting piece 1 at 02-NOV-12 released channel: ch1 RMAN-00571: RMA ...

  3. HDFS Corrupt blocks 解决方法

    查看修复HDFS中损坏的块 检测缺失块 1 hdfs fsck -list-corruptfileblocks 1 hdfs fsck / | egrep -v '^\.+$' | grep -v e ...

  4. hdfs missing blocks corrupt blocks

    环境: CDH集群 问题描述: Cloudera Manager 监控HDFS爆红 Canary 测试无法为 /tmp/.cloudera_health_monitoring_canary_files ...

  5. DBMS_REPAIR

    DBMS_REPAIR只是把table及index的corruption blocks标识后忽略,在下次查询或操作时不会对corruption blocks操作,不会对corruption block ...

  6. ambari hdfs 启动报错_HDFS 运维常见问题处理

    腾讯游戏CROS体系的DBA维护着多套互娱数据平台的核心HDFS集群,积累了不少维护经验. 1. 定期block全盘扫描,引起dn心跳超时而脱离集群 hdfs有一个目录扫描机制,默认6小时会全盘扫描一 ...

  7. HDFS副本设置——默认3

    首先 dfs.replication这个参数是个client参数,即node level参数.需要在每台datanode上设置. 其实默认为3个副本已经够用了,设置太多也没什么用. 一个文件,上传到h ...

  8. shell 删除了hdfs 文件_从零开始学大数据(三) Shell操作HDFS文件系统-中

    1.格式化 [root@master sbin]# hdfs namenode -format 2.命令hdfs dfsadmin 查看(hdfs dfsadmin -report) [root@ma ...

  9. hdfs fsck命令查看HDFS文件对应的文件块信息(Block)和位置信息(Locations)

    关键字:hdfs fsck.block.locations 在HDFS中,提供了fsck命令,用于检查HDFS上文件和目录的健康状态.获取文件的block信息和位置信息等. fsck命令必须由HDFS ...

最新文章

  1. 中国最新奥数竞赛成绩出炉:南师大附中女生严彬玮满分夺冠!60人国家集训队名单公布...
  2. 计算机游戏系统分析,计算机游戏引擎fly3D系统的实现方式及应用技巧
  3. JAVA——System.in作为控制台输入时结束输入(输入EOF)解决方案
  4. count sort, radix sort, bucket sort
  5. [你必须知道的.NET] 第一回:恩怨情仇:is和as
  6. 弗林的计算机体系结构分类
  7. Redis哈希数详解
  8. 疫情加速中国服务器采购 数字化转型成为增长“新引擎”
  9. 微信小程序遇到的那些坑
  10. 涨价潮或延续至下半年 芯片国产化遇机遇
  11. Atitit 软件与互联网理论 attilax总结
  12. AIML框架标签详解
  13. 视频通信系统的关键技术与挑战
  14. 解决postgre报错ERROR #22P02 malformed array literal
  15. 贪吃蛇c语言程序 简书,贪吃蛇游戏(scratch编程)
  16. 可汗学院-统计学-学习笔记
  17. finecms php7cms,FineCMS评测 是精简版的Phpcms v9?
  18. 魅族16 USB连接计算机,在魅族16x中连接电脑的方法分享
  19. 魔方机器人大赛——魔方步骤转换算法
  20. 区块链游戏- Solcery(Summoner 召唤者)

热门文章

  1. Gerrit 服务搭建和升级详解(包括 H2 数据库迁移 MySQL 步骤)
  2. 猜数游戏控制猜测次数c语言,C语言小游戏之猜数字,三子棋游戏
  3. 吸顶灯怎么固定天花板_什么是吸顶灯?吸顶灯的材质和其与吊顶灯的区别分析...
  4. macOS下JetBrains配置修改错误导致无法启动解决方案
  5. 【CCCC】L2-007 家庭房产 (25分),并查集,结构统计
  6. 【Luogu2085】最小函数值(优先队列)
  7. 嵌入式系统中断实验c语言,中断的实验现象
  8. JavaScript文档对象模型document对象改变Html元素内容(3)
  9. java模拟多个用户操作,JAVA 模拟多用户提交动作
  10. 一维树桩数组区间更新、区间查询