The replication factor is a property that can be set in the HDFS configuration file( hdfs-site.xml).This will be to set global replication factor for the entire cluster.This will only work on the newly created files but not on the existing files. The Replication factor default value is 3, however for cluster in Pseudo distributed mode its 1.The replication factor value is configurable in hdfs-site.xml file.You have to change dfs.replication to a desired value.
This file is usually found in the conf folder of the Hadoop installation directory. <property> <name>dfs.replication</name> <value>(desired value)</value> </property>
Change the replication factor on a per-file basis : hadoop fs –setrep –w 3 /file/filename.xml
-setrep commnad to change the replication factor for files that already exist in HDFS.-R flag would recursively change the replication factor on all the files