I have set the replication factor for my file as follows:
hadoop fs -D dfs.replication=5 -copyFromLocal file.txt /user/xxxx
When a NameNode
restarts, it makes sure under-replicated blocks are replicated.
Hence the replication info for the file is stored (possibly in nameNode
). How can I get that information?
You can run following command to get replication factor,
The second column in the output signify replication factor for the file and for the folder it shows
-
, as shown in below pic.Apart from Alexey Shestakov's answer, which works perfectly and does exactly what you ask, other ways, mostly found here, include:
which shows the replication factors of all the
/parent/path
contents on the second column.Through Java, you can get this information by using:
You can also see the replication factors of files by using:
Finally, from the web UI of the namenode, I believe that this information is also available (didn't check that).
We can use following commands to check replication of the file.
or
Try to use command
hadoop fs -stat %r /path/to/file
, it should print the replication factor.