In this post, I will explain about how you can change the Replication Factor of a file in HDFS

At first make sure, all components of Hadoop are started.

Create a new directory

Copy two text files to the newly created Directory in HDFS

Make a note of the Replication factor that is being set for the two files. By default the Replication Factor is 1 (as set in the conf file in my Hadoop Installation)

Now change the Replication factor of file “file1.txt” using

The replication factor of file “file1.txt” is now changed to 4.

To change Replication factor of all files in a given directory in HDFS use