hadoop hdfs 命令使用
參考連結:
在HDFS中,提供了fsck命令,用於檢查HDFS上檔案和目錄的健康狀態、獲取檔案的block資訊和位置資訊等。
fsck命令必須由HDFS超級使用者來執行,普通使用者無許可權。
- [hadoop@dev~]$ hdfs fsck
- Usage:DFSck[-list-corruptfileblocks|[-move|-delete|-openforwrite][-files[-blocks[-locations|-racks]]]]
- start checkingfromthispath
- -move move corrupted files to/lost+found
- -deletedeletecorrupted files
- -filesprintoutfiles beingchecked
- -openforwriteprintoutfiles openedforwrite
- -includeSnapshots include snapshot dataifthe given path indicates a snapshottable directoryorthere are snapshottable directories under it
- -list-corruptfileblocksprintoutlist of missing blocksandfiles they belong to
- -blocksprintoutblock report
- -locationsprintoutlocationsforevery block
- -racksprintoutnetwork topologyfordata-node locations
下面介紹每一個選項的含義及用法。
檢視檔案中損壞的塊(-list-corruptfileblocks)
- [hadoop@dev~]$ hdfs fsck/hivedata/warehouse/liuxiaowen.db/lxw_product_names/-list-corruptfileblocks
- Thefilesystem under path'/hivedata/warehouse/liuxiaowen.db/lxw_product_names/'has0CORRUPT files
將損壞的檔案移動至/lost+found目錄(-move)
- [hadoop@dev~]$ hdfs fsck/hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-00168-move
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-00168atThuAug1309:36:35CST2015
- .Status:HEALTHY
- Totalsize:13497058B
- Totaldirs:0
- Totalfiles:1
- Totalsymlinks:0
- Totalblocks(validated):1(avg.block size13497058B)
- Minimallyreplicated blocks:1(100.0%)
- Over-replicated blocks:0(0.0%)
- Under-replicated blocks:0(0.0%)
- Mis-replicated blocks:0(0.0%)
- Defaultreplication factor:2
- Averageblock replication:2.0
- Corruptblocks:0
- Missingreplicas:0(0.0%)
- Numberof data-nodes:15
- Numberof racks:1
- FSCK ended atThuAug1309:36:35CST2015in1milliseconds
- Thefilesystem under path'/hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-00168'isHEALTHY
刪除損壞的檔案(-delete)
- [hadoop@dev~]$ hdfs fsck/hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-00168-delete
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-00168atThuAug1309:37:58CST2015
- .Status:HEALTHY
- Totalsize:13497058B
- Totaldirs:0
- Totalfiles:1
- Totalsymlinks:0
- Totalblocks(validated):1(avg.block size13497058B)
- Minimallyreplicated blocks:1(100.0%)
- Over-replicated blocks:0(0.0%)
- Under-replicated blocks:0(0.0%)
- Mis-replicated blocks:0(0.0%)
- Defaultreplication factor:2
- Averageblock replication:2.0
- Corruptblocks:0
- Missingreplicas:0(0.0%)
- Numberof data-nodes:15
- Numberof racks:1
- FSCK ended atThuAug1309:37:58CST2015in1milliseconds
- Thefilesystem under path'/hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-00168'isHEALTHY
檢查並列出所有檔案狀態(-files)
- [hadoop@dev~]$ hdfs fsck/hivedata/warehouse/liuxiaowen.db/lxw_product_names/-files
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/hivedata/warehouse/liuxiaowen.db/lxw_product_names/atThuAug1309:39:38CST2015
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/dir
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/_SUCCESS0bytes,0block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000013583807bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000113577427bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000213588601bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000313479213bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000413497012bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000513557451bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000613580267bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000713486035bytes,1block(s):OK
- /hivedata/warehouse/liuxiaowen.db/lxw_product_names/part-0000813481498bytes,1block(s):OK
- ...
檢查並列印正在被開啟執行寫操作的檔案(-openforwrite)
- [hadoop@dev~]$ hdfs fsck/hivedata/warehouse/liuxiaowen.db/lxw_product_names/-openforwrite
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/hivedata/warehouse/liuxiaowen.db/lxw_product_names/atThuAug1309:41:28CST2015
- ....................................................................................................
- ....................................................................................................
- .Status:HEALTHY
- Totalsize:2704782548B
- Totaldirs:1
- Totalfiles:201
- Totalsymlinks:0
- Totalblocks(validated):200(avg.block size13523912B)
- Minimallyreplicated blocks:200(100.0%)
- Over-replicated blocks:0(0.0%)
- Under-replicated blocks:0(0.0%)
- Mis-replicated blocks:0(0.0%)
- Defaultreplication factor:2
- Averageblock replication:2.0
- Corruptblocks:0
- Missingreplicas:0(0.0%)
- Numberof data-nodes:15
- Numberof racks:1
- FSCK ended atThuAug1309:41:28CST2015in10milliseconds
- Thefilesystem under path'/hivedata/warehouse/liuxiaowen.db/lxw_product_names/'isHEALTHY
列印檔案的Block報告(-blocks)
需要和-files一起使用。
- [hadoop@dev~]$ hdfs fsck/logs/site/2015-08-08/lxw1234.log-files-blocks
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/logs/site/2015-08-08/lxw1234.log atThuAug1309:45:59CST2015
- /logs/site/2015-08-08/lxw1234.log7408754725bytes,56block(s):OK
- 0.BP-1034052771-172.16.212.130-1405595752491:blk_1075892982_2152381 len=134217728repl=2
- 1.BP-1034052771-172.16.212.130-1405595752491:blk_1075892983_2152382 len=134217728repl=2
- 2.BP-1034052771-172.16.212.130-1405595752491:blk_1075892984_2152383 len=134217728repl=2
- 3.BP-1034052771-172.16.212.130-1405595752491:blk_1075892985_2152384 len=134217728repl=2
- 4.BP-1034052771-172.16.212.130-1405595752491:blk_1075892997_2152396 len=134217728repl=2
- 5.BP-1034052771-172.16.212.130-1405595752491:blk_1075892998_2152397 len=134217728repl=2
- 6.BP-1034052771-172.16.212.130-1405595752491:blk_1075892999_2152398 len=134217728repl=2
- 7.BP-1034052771-172.16.212.130-1405595752491:blk_1075893000_2152399 len=134217728repl=2
- 8.BP-1034052771-172.16.212.130-1405595752491:blk_1075893001_2152400 len=134217728repl=2
- 9.BP-1034052771-172.16.212.130-1405595752491:blk_1075893002_2152401 len=134217728repl=2
- 10.BP-1034052771-172.16.212.130-1405595752491:blk_1075893003_2152402 len=134217728repl=2
- 11.BP-1034052771-172.16.212.130-1405595752491:blk_1075893004_2152403 len=134217728repl=2
- 12.BP-1034052771-172.16.212.130-1405595752491:blk_1075893005_2152404 len=134217728repl=2
- 13.BP-1034052771-172.16.212.130-1405595752491:blk_1075893006_2152405 len=134217728repl=2
- 14.BP-1034052771-172.16.212.130-1405595752491:blk_1075893007_2152406 len=134217728repl=2
- ...
其中,/logs/site/2015-08-08/lxw1234.log 7408754725 bytes, 56 block(s): 表示檔案的總大小和block數;
0. BP-1034052771-172.16.212.130-1405595752491:blk_1075892982_2152381 len=134217728 repl=2
1. BP-1034052771-172.16.212.130-1405595752491:blk_1075892983_2152382 len=134217728 repl=2
2. BP-1034052771-172.16.212.130-1405595752491:blk_1075892984_2152383 len=134217728 repl=2
前面的0. 1. 2.代表該檔案的block索引,56的檔案塊,就從0-55;
BP-1034052771-172.16.212.130-1405595752491:blk_1075892982_2152381表示block id;
len=134217728 表示該檔案塊大小;
repl=2 表示該檔案塊副本數;
列印檔案塊的位置資訊(-locations)
需要和-files -blocks一起使用。
- [hadoop@dev~]$ hdfs fsck/logs/site/2015-08-08/lxw1234.log-files-blocks-locations
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/logs/site/2015-08-08/lxw1234.log atThuAug1309:45:59CST2015
- /logs/site/2015-08-08/lxw1234.log7408754725bytes,56block(s):OK
- 0.BP-1034052771-172.16.212.130-1405595752491:blk_1075892982_2152381 len=134217728repl=2[172.16.212.139:50010,172.16.212.135:50010]
- 1.BP-1034052771-172.16.212.130-1405595752491:blk_1075892983_2152382 len=134217728repl=2[172.16.212.140:50010,172.16.212.133:50010]
- 2.BP-1034052771-172.16.212.130-1405595752491:blk_1075892984_2152383 len=134217728repl=2[172.16.212.136:50010,172.16.212.141:50010]
- 3.BP-1034052771-172.16.212.130-1405595752491:blk_1075892985_2152384 len=134217728repl=2[172.16.212.133:50010,172.16.212.135:50010]
- 4.BP-1034052771-172.16.212.130-1405595752491:blk_1075892997_2152396 len=134217728repl=2[172.16.212.142:50010,172.16.212.139:50010]
- 5.BP-1034052771-172.16.212.130-1405595752491:blk_1075892998_2152397 len=134217728repl=2[172.16.212.133:50010,172.16.212.139:50010]
- 6.BP-1034052771-172.16.212.130-1405595752491:blk_1075892999_2152398 len=134217728repl=2[172.16.212.141:50010,172.16.212.135:50010]
- 7.BP-1034052771-172.16.212.130-1405595752491:blk_1075893000_2152399 len=134217728repl=2[172.16.212.144:50010,172.16.212.142:50010]
- 8.BP-1034052771-172.16.212.130-1405595752491:blk_1075893001_2152400 len=134217728repl=2[172.16.212.133:50010,172.16.212.138:50010]
- 9.BP-1034052771-172.16.212.130-1405595752491:blk_1075893002_2152401 len=134217728repl=2[172.16.212.140:50010,172.16.212.134:50010]
- ...
和列印出的檔案塊資訊相比,多了一個檔案塊的位置資訊:[172.16.212.139:50010, 172.16.212.135:50010]
列印檔案塊位置所在的機架資訊(-racks)
- [hadoop@dev~]$ hdfs fsck/logs/site/2015-08-08/lxw1234.log-files-blocks-locations-racks
- FSCK startedbyhadoop(auth:SIMPLE)from/172.16.212.17forpath/logs/site/2015-08-08/lxw1234.log atThuAug1309:45:59CST2015
- /logs/site/2015-08-08/lxw1234.log7408754725bytes,56block(s):OK
- 0.BP-1034052771-172.16.212.130-1405595752491:blk_1075892982_2152381 len=134217728repl=2[/default-rack/172.16.212.139:50010,/default-rack/172.16.212.135:50010]
- 1.BP-1034052771-172.16.212.130-1405595752491:blk_1075892983_2152382 len=134217728repl=2[/default-rack/172.16.212.140:50010,/default-rack/172.16.212.133:50010]
- 2.BP-1034052771-172.16.212.130-1405595752491:blk_1075892984_2152383 len=134217728repl=2[/default-rack/172.16.212.136:50010,/default-rack/172.16.212.141:50010]
- 3.BP-1034052771-172.16.212.130-1405595752491:blk_1075892985_2152384 len=134217728repl=2[/default-rack/172.16.212.133:50010,/default-rack/172.16.212.135:50010]
- 4.BP-1034052771-172.16.212.130-1405595752491:blk_1075892997_2152396 len=134217728repl=2[/default-rack/172.16.212.142:50010,/default-rack/172.16.212.139:50010]
- 5.BP-1034052771-172.16.212.130-1405595752491:blk_1075892998_2152397 len=134217728repl=2[/default-rack/172.16.212.133:50010,/default-rack/172.16.212.139:50010]
- ...
和前面列印出的資訊相比,多了機架資訊:[/default-rack/172.16.212.139:50010, /default-rack/172.16.212.135:50010]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31347383/viewspace-2119093/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Hadoop Shell命令 |HDFS Shell命令| HDFS 命令Hadoop
- hadoop命令——hdfsHadoop
- hadoop hdfs命令彙總Hadoop
- HDFS 命令:用於管理HDFS的Hadoop Shell命令大全Hadoop
- hadoop hdfs 常用命令Hadoop
- hadoop之 HDFS fs 命令總結Hadoop
- hadoop HDFS之常用命令Hadoop
- Hadoop的HDFS 入門使用Hadoop
- Hadoop框架:HDFS簡介與Shell管理命令Hadoop框架
- Hadoop–HDFSHadoop
- Apache Hadoop文件翻譯之二(HDFS命令指南)ApacheHadoop
- 【大資料】【hadoop】檢視hdfs檔案命令大資料Hadoop
- Hadoop HDFS(二)Hadoop
- Hadoop HDFS(一)Hadoop
- Hadoop系列006-HDFS概念及命令列操作Hadoop命令列
- HDFS Federation(HDFS 聯邦)(Hadoop2.3)Hadoop
- hadoop: hdfs API示例HadoopAPI
- hdfs命令
- Hadoop學習之路(十)HDFS API的使用HadoopAPI
- hadoop之 HDFS-Hadoop存檔Hadoop
- root加到hadoop的hdfs使用者組內Hadoop
- Hadoop面試題之HDFSHadoop面試題
- Hadoop原理之——HDFS原理Hadoop
- Hadoop筆記HDFS(1)Hadoop筆記
- Hadoop筆記HDFS(2)Hadoop筆記
- 漫談Hadoop HDFS BalancerHadoop
- hadoop 2.0 hdfs HA 搭建Hadoop
- Hadoop(十)HDFS API操作HadoopAPI
- HDFS shell命令
- Hadoop HDFS分散式檔案系統 常用命令彙總Hadoop分散式
- Hadoop KMS配置(HDFS透明加密)Hadoop加密
- Hadoop學習筆記—HDFSHadoop筆記
- 【HDFS】HADOOP DISTRIBUTED FILE SYSTEMHadoop
- Hadoop HDFS 設計隨想Hadoop
- hadoop-HDFS優缺點Hadoop
- 【Hadoop】HDFS的執行原理Hadoop
- Hadoop偽分佈模式(HDFS)Hadoop模式
- Hadoop 基礎之 HDFS 入門Hadoop