获取hdfs没有正常关闭的文件并删除
2015-03-17 14:20
211 查看
由于hdfs文件系统中存在损坏的文件导致mapreducejob执行出错:
使用以下命令搜索HDFS文件没有正常关闭的文件:
hadoop fsck /logs/ -files -openforwrite | grep "MISSING"
将搜索到的文件写入文件:
hadoop fsck /logs/ -files -openforwrite | grep "MISSING" > test.txt
test.txt 内容如下:
test_1999-01-11-14.log.14b52615a49ZZ28520@test1.file 2573 bytes, 1 block(s), OPENFORWRITE: MISSING 1 blocks of total size 2573 B
test_1999-01-13-22.log.14b2ab99756ZZ18137@test2.file 897 bytes, 1 block(s), OPENFORWRITE: MISSING 1 blocks of total size 897 B
cat test.txt | awk -F ' ' '{print $1}'
[dataanalyze@n1 ~]$ cat a1.txt | awk -F ' ' '{print $1}'
test_1999-11-17-18.log.14b52615a49ZZ28520@test1.file
test_1999-01-04-22.log.14b2ab99756ZZ18137@test2.file
删除损坏的文件:
testt test.txt | awk -F ' ' '{print $1}' | xargs hdfs dfs -rm {}
使用以下命令搜索HDFS文件没有正常关闭的文件:
hadoop fsck /logs/ -files -openforwrite | grep "MISSING"
将搜索到的文件写入文件:
hadoop fsck /logs/ -files -openforwrite | grep "MISSING" > test.txt
test.txt 内容如下:
test_1999-01-11-14.log.14b52615a49ZZ28520@test1.file 2573 bytes, 1 block(s), OPENFORWRITE: MISSING 1 blocks of total size 2573 B
test_1999-01-13-22.log.14b2ab99756ZZ18137@test2.file 897 bytes, 1 block(s), OPENFORWRITE: MISSING 1 blocks of total size 897 B
cat test.txt | awk -F ' ' '{print $1}'
[dataanalyze@n1 ~]$ cat a1.txt | awk -F ' ' '{print $1}'
test_1999-11-17-18.log.14b52615a49ZZ28520@test1.file
test_1999-01-04-22.log.14b2ab99756ZZ18137@test2.file
删除损坏的文件:
testt test.txt | awk -F ' ' '{print $1}' | xargs hdfs dfs -rm {}
相关文章推荐
- eclipse上hdfs的javaapi调用文件或者获取节点信息没有权限
- Winodws删除目录失败--查找文件句柄没有关闭
- 文件的删除和获取文件的信息
- 在PROCESS没有结束前就将启动PROCESS的EXE文件删除
- c# 打开exe文件与关闭exe文件 c#服务打开exe时候默认是没有窗体界面的
- linux删除文件后没有释放空间
- C#用Com组件解析Excel文件 然后删除Excel 并且彻底关闭Excel进程(公司实战项目经验)
- 在没有备份情况下误删除数据文件的恢复
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)
- Vista瘦身计划:关闭虚拟内存和删除休眠文件
- c# 打开exe文件与关闭exe文件 c#服务打开exe时候默认是没有窗体界面的
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)
- [导入]Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(二)
- MSDN:为了防止数据丢失,请关闭文件后再删除它们
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(二)
- 【原创】ASP.NET C# 获取指定目录文件的排序和删除
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(二)
- [转]Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)
- 自己写的处理文件的类,删除目录,复制目录,遍历目录,获取文件属性,点评一下啊