Wednesday, 23 March 2022

Hadoop: How to get the replication factor of a hdfs file?

Approach 1: Using ls command.

$hadoop fs -ls -h /user/cloudera/demo1
Found 4 items
-rw-r--r--   1 cloudera cloudera      5.9 M 2022-03-22 23:57 /user/cloudera/demo1/atlas.docx
-rw-r--r--   1 cloudera cloudera      8.7 M 2022-03-22 23:57 /user/cloudera/demo1/atlasClient.docx
-rw-r--r--   1 cloudera cloudera      6.7 M 2022-03-22 23:58 /user/cloudera/demo1/gradle.docx
-rw-r--r--   1 cloudera cloudera      8.6 M 2022-03-22 23:58 /user/cloudera/demo1/maven.docx

 

Second column in the output specifies the replication factor of a file. In my case it is set to 1 for all the files.

 

Approach 2: Using stat command.

 

Example

hdfs dfs -stat %r {file_path_in_hdfs}

$hadoop fs -stat %r /user/cloudera/demo1/atlas.docx
1

 


 


Previous                                                 Next                                                 Home

No comments:

Post a Comment