hdfs文件3個副本BLK的查找

開始部署hdfs的時候,文件冗餘3份。那麼1個文件分拆成那些BLK,分別存儲在那裏呢?


hadoop fsck <需要找的文件名> -files -blocks -locations 語句幫你忙。


#######################

[root@master ~]# hadoop fsck --help
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.


Usage: DFSck <path> [-list-corruptfileblocks | [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]]
        <path>  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


Please Note:
        1. By default fsck ignores files opened for write, use -openforwrite to report such files. They are usually  tagged CORRUPT or HEALTHY depending on 


their block allocation status
        2. Option -includeSnapshots should not be used for comparing stats, should be used only for HEALTH check, as this may contain duplicates if the same 


file present in both original fs tree and inside snapshots.


Generic options supported are
-conf <configuration file>     specify an application configuration file
-D <property=value>            use value for given property
-fs <local|namenode:port>      specify a namenode
-jt <local|resourcemanager:port>    specify a ResourceManager
-files <comma separated list of files>    specify comma separated files to be copied to the map reduce cluster
-libjars <comma separated list of jars>    specify comma separated jar files to include in the classpath.
-archives <comma separated list of archives>    specify comma separated archives to be unarchived on the compute machines.


The general command line syntax is
bin/hadoop command [genericOptions] [commandOptions]


[root@master ~]#


###################################   例子:####################################################################


[hdfs@slave1 NEW]$ hadoop fsck /user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv -files -blocks -locations
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.


Connecting to namenode via http://snn.hadoop:50070
FSCK started by hdfs (auth:SIMPLE) from /192.168.100.13 for path /user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv at Sat Dec 05 22:18:36 HKT 2015
/user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv 8472 bytes, 1 block(s):  OK
0. BP-170662068-192.168.100.11-1447496766461:blk_1073746407_5690 len=8472 Live_repl=3 [DatanodeInfoWithStorage[192.168.100.12:50010,DS-6db5c6fb-018c-446f-94cb-adfeed0e5222,DISK], DatanodeInfoWithStorage[192.168.100.10:50010,DS-fb298bf6-404c-46ad-848d-070ad0637248,DISK], DatanodeInfoWithStorage[192.168.100.15:50010,DS-fcc3d5f1-410f-4d69-aa4f-24064bf8c681,DISK]]


Status: HEALTHY
 Total size:    8472 B
 Total dirs:    0
 Total files:   1
 Total symlinks:                0
 Total blocks (validated):      1 (avg. block size 8472 B)
 Minimally replicated blocks:   1 (100.0 %)
 Over-replicated blocks:        0 (0.0 %)
 Under-replicated blocks:       0 (0.0 %)
 Mis-replicated blocks:         0 (0.0 %)
 Default replication factor:    3
 Average block replication:     3.0
 Corrupt blocks:                0
 Missing replicas:              0 (0.0 %)
 Number of data-nodes:          5
 Number of racks:               1
FSCK ended at Sat Dec 05 22:18:36 HKT 2015 in 4 milliseconds




The filesystem under path '/user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv' is HEALTHY
[hdfs@slave1 NEW]$


#############################


hdfs fsck <file_name> -files -blocks -locations


#############################


[hdfs@slave1 NEW]$ hdfs fsck /user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv -files -blocks -locations
Connecting to namenode via http://snn.hadoop:50070
FSCK started by hdfs (auth:SIMPLE) from /192.168.100.13 for path /user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv at Sat Dec 05 22:20:19 HKT 2015
/user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv 8472 bytes, 1 block(s):  OK
0. BP-170662068-192.168.100.11-1447496766461:blk_1073746407_5690 len=8472 Live_repl=3 [DatanodeInfoWithStorage[192.168.100.12:50010,DS-6db5c6fb-018c-446f-94cb-adfeed0e5222,DISK], DatanodeInfoWithStorage[192.168.100.10:50010,DS-fb298bf6-404c-46ad-848d-070ad0637248,DISK], DatanodeInfoWithStorage[192.168.100.15:50010,DS-fcc3d5f1-410f-4d69-aa4f-24064bf8c681,DISK]]


Status: HEALTHY
 Total size:    8472 B
 Total dirs:    0
 Total files:   1
 Total symlinks:                0
 Total blocks (validated):      1 (avg. block size 8472 B)
 Minimally replicated blocks:   1 (100.0 %)
 Over-replicated blocks:        0 (0.0 %)
 Under-replicated blocks:       0 (0.0 %)
 Mis-replicated blocks:         0 (0.0 %)
 Default replication factor:    3
 Average block replication:     3.0
 Corrupt blocks:                0
 Missing replicas:              0 (0.0 %)
 Number of data-nodes:          5
 Number of racks:               1
FSCK ended at Sat Dec 05 22:20:19 HKT 2015 in 1 milliseconds




The filesystem under path '/user/hue/external/tbl_8005/Finance_inequality_and_the_poor_data_8005.csv' is HEALTHY
[hdfs@slave1 NEW]$




##############################


blk_1073746407




find / -name "blk_1073746407*"


192.168.100.15:


[root@slave3 subdir17]# pwd
/dfs/dn/current/BP-170662068-192.168.100.11-1447496766461/current/finalized/subdir0/subdir17
[root@slave3 subdir17]# ll blk_1073746407*
-rw-r--r-- 1 hdfs hdfs 8472 Dec  4 22:19 blk_1073746407
-rw-r--r-- 1 hdfs hdfs   75 Dec  4 22:19 blk_1073746407_5690.meta
[root@slave3 subdir17]#
[root@slave3 subdir17]#
[root@slave3 subdir17]#
[root@slave3 subdir17]#
[root@slave3 subdir17]#


#######


192.168.100.12


[root@master ~]# ssh snn.hadoop
Last login: Sat Dec  5 13:25:46 2015 from 192.168.100.1
[root@snn ~]# find / -name "blk_1073746407*"
/dfs/dn/current/BP-170662068-192.168.100.11-1447496766461/current/finalized/subdir0/subdir17/blk_1073746407
/dfs/dn/current/BP-170662068-192.168.100.11-1447496766461/current/finalized/subdir0/subdir17/blk_1073746407_5690.meta
[root@snn ~]#
[root@snn ~]#
[root@snn ~]#




#######


192.168.100.10


[root@archive ~]# find / -name "blk_1073746407*"
/dfs/dn/current/BP-170662068-192.168.100.11-1447496766461/current/finalized/subd                                                                              ir0/subdir17/blk_1073746407
/dfs/dn/current/BP-170662068-192.168.100.11-1447496766461/current/finalized/subd                                                                              ir0/subdir17/blk_1073746407_5690.meta
[root@archive ~]#
[root@archive ~]#



########################

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章