Introduction
Welcome to the magical world of Hadoop Snapshot Management! In this lab, you will embark on a journey through a enchanting forest where you will meet a mysterious tree spirit known as Leafa. Your goal is to learn the art of managing snapshots in Hadoop HDFS while exploring the wonders of this mystical realm.
Creating a Snapshot
In this step, you will learn how to create a snapshot of a directory in HDFS.
Open a terminal and switch to the
hadoopuser:su - hadoopCreate a directory in HDFS:
hdfs dfs -mkdir /user/hadoop/snapshot_demoPopulate the directory with some sample files:
echo "Hello, World" > /home/hadoop/sample.txthdfs dfs -put /home/hadoop/sample.txt /user/hadoop/snapshot_demo/Allow snapshots on the directory:
hdfs dfsadmin -allowSnapshot /user/hadoop/snapshot_demoVerify that the directory is snapshottable:
hdfs lsSnapshottableDirCreate a snapshot of the directory:
hdfs dfs -createSnapshot /user/hadoop/snapshot_demo snapshot1Verify the snapshot creation:
hdfs dfs -ls /user/hadoop/snapshot_demo/.snapshot/snapshot1
Restoring a Snapshot
In this step, you will learn how to restore a directory from a snapshot in HDFS.
Create a directory in HDFS:
hdfs dfs -mkdir /user/hadoop/restored_snapshot_demoRestore the directory from the created snapshot:
hdfs dfs -cp /user/hadoop/snapshot_demo/.snapshot/snapshot1 /user/hadoop/restored_snapshot_demoVerify the contents of the restored directory:
hdfs dfs -cat /user/hadoop/restored_snapshot_demo/snapshot1/sample.txt
Deleting a Snapshot
In this step, you will learn how to delete a previously created snapshot in Hadoop's HDFS.
Delete the snapshot created in the first step:
hdfs dfs -deleteSnapshot /user/hadoop/snapshot_demo snapshot1Verify the snapshot deletion:
hdfs dfs -ls /user/hadoop/snapshot_demo/.snapshot
Summary
In this lab, we delved into the realm of Hadoop Snapshot Management by creating, restoring, and deleting snapshots in HDFS. Through these hands-on exercises, you gained practical experience in handling snapshots, a crucial aspect of managing data in Hadoop. By mastering snapshot management, you are now equipped with a powerful tool for data backup and recovery in your Hadoop ecosystem. Happy exploring the magical world of Hadoop!



