In spite of having high availability and replication factor as three, there are chances of data loss due to accidental deletions or corruptions. What if the user wants to restore the HDFS state to a previous point in time? Can that be done?
To address these issues, HDFS supports snapshots, which is a kind of backup in a point of time. However, snapshots do not occupy any extra space, as these are simply pointers to the original data blocks.
In this recipe, we will see how the snapshots can be enabled and configured.
Make sure that the user has a running cluster with HDFS configured. The user must be able to execute HDFS commands and copy some data to the cluster.
Connect to the
master1.cyrus.com
Namenode and switch to the userhadoop
.The first step is to enable a snapshot on a directory, as shown in the following command:
$ hdfs dfsadmin -allowSnapshot /projects
The preceding command makes a directory snapshot able and
.snapshot
directory will be created...