hadoophdfsreplicationambarifsck

Changing replication of existing files in HDFS


I tried changing the replica factor from 3 to 1 and restarting the services. But the replication factor remains the same

Can anyone suggest me how to change the replication factor of existing files?

This is the fsck report:

 Minimally replicated blocks:   45 (100.0 %)

 Over-replicated blocks:        0 (0.0 %)

 Under-replicated blocks:       45 (100.0 %)

 Mis-replicated blocks:         0 (0.0 %)

 Default replication factor:    1

 Average block replication:     2.0

 Corrupt blocks:                0

 Missing replicas:              45 (33.333332 %)

 DecommissionedReplicas:        45

 Number of data-nodes:          2

 Number of racks:               1

Solution

  • For anyone who is facing the same issue just run this command :

    hdfs dfs -setrep -R 1 /
    

    Because when the blocks are under-replicated and you change the replication factor from 3 to 1(or any changes) then these changes are for the new files which will be created in HDFS, not for the old ones.

    You have to change the replication factor of old files on your own.