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?

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 by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *