Skip to content

Instantly share code, notes, and snippets.

@kawamon
Created June 12, 2020 08:25
Show Gist options
  • Save kawamon/f3014d588ffc206fff0632c764956d67 to your computer and use it in GitHub Desktop.
Save kawamon/f3014d588ffc206fff0632c764956d67 to your computer and use it in GitHub Desktop.
hdfs snapshot test
hdfs dfsadmin -allowSnapshot contents
Allowing snapshot on contents succeeded
hdfs lsSnapshottableDir
drwxr-xr-x 0 training supergroup 0 2020-06-12 01:23 0 65536 /user/training/contents
hdfs dfs -createSnapshot /user/training/contents snapshotv1
Created snapshot /user/training/contents/.snapshot/snapshotv1
hdfs dfs -ls /user/training/contents/.snapshot/
Found 1 items
drwxr-xr-x - training supergroup 0 2020-06-12 01:23 /user/training/contents/.snapshot/snapshotv1
hdfs dfs -ls /user/training/contents/.snapshot/snapshotv1/
Found 16 items
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/BTESTB.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/TESTA.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/TESTB.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/TSTC.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/a.txt
-rw-r--r-- 3 training supergroup 26882 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/access.log
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/aget.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/atesta.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/b.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/c.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/d.txt
-rw-r--r-- 3 training supergroup 79 2020-06-12 01:23 /user/training/contents/.snapshot/snapshotv1/hosts
-rw-r--r-- 3 training supergroup 330 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/localmerge.txt
-rw-r--r-- 3 training supergroup 535 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/test.zip
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/testa.txt
-rw-r--r-- 3 training supergroup 110 2020-06-12 00:39 /user/training/contents/.snapshot/snapshotv1/testb.txt
hdfs dfs -createSnapshot /user/training/contents snapshotv2
Created snapshot /user/training/contents/.snapshot/snapshotv2
hdfs dfs -rm contents/hosts
20/06/12 01:23:38 INFO fs.TrashPolicyDefault: Moved: 'hdfs://localhost.localdomain:8020/user/training/contents/hosts' to trash at: hdfs://localhost.localdomain:8020/user/training/.Trash/Current/user/training/contents/hosts
hdfs dfs -createSnapshot /user/training/contents snapshotv3
Created snapshot /user/training/contents/.snapshot/snapshotv3
hdfs snapshotDiff /user/training/contents snapshotv2 snapshotv3
Difference between snapshot snapshotv2 and snapshot snapshotv3 under directory /user/training/contents:
M .
+ ./services
- ./hosts
hdfs dfsadmin -disallowSnapshot contents
disallowSnapshot: The directory /user/training/contents has snapshot(s). Please redo the operation after removing all the snapshots.
hdfs dfs -deleteSnapshot /user/training/contents snapshotv1
hdfs dfs -deleteSnapshot /user/training/contents snapshotv3
hdfs dfs -deleteSnapshot /user/training/contents snapshotv2
hdfs dfsadmin -disallowSnapshot contents
Disallowing snapshot on contents succeeded
hdfs lsSnapshottableDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment