How to check the replication factor of a file in HDFS?

A related question: how to find the replication factors of files in a HDFS cluster?

asked Nov 15, 2014 by Eric Z Ma (44,280 points)
edited Feb 1, 2015 by Eric Z Ma

1 Answer

 
Best answer

method 1: You can use the HDFS command line to ls the file.

The second column of the output will show the replication factor of the file.

For example,

$ hdfs dfs -ls  /usr/GroupStorage/data1/out.txt
-rw-r--r--   3 hadoop zma 11906625598 2014-10-22 18:35 /usr/GroupStorage/data1/out.txt

The out.txt's replication factor is 3.

method 2: Get the replication factor using the stat hdfs command tool.

Using the above file as an example:

$ hdfs dfs -stat %r /usr/GroupStorage/data1/out.txt

It will print 3.

answered Nov 15, 2014 by Eric Z Ma (44,280 points)
edited Oct 30, 2016 by Eric Z Ma

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...