The replication factor of a file in HDFS can be changed using code example
Example 1: change replication factor hadoop cluster command
hdfs dfs -setrep -R 2 /user/hdfs/test
Example 2: change replication factor hadoop cluster command
-D dfs.replication=1