在hdfs中,默许的文件删除保存的时间是0,也就是没有保存删除的文件,删除即丢失
那末如果你想启用hdfs的回收站机制,在删除文件后,希望多久以后,文件才消失,由于这个进程中万1你想来恢复文件呢
<property>
<name>fs.trash.interval</name>
<value>1440</value>
</property>
将以上配置添加到core-site.xml中便可,1440表示删除的文件保存1440分钟,在这个期间你都可以恢复你的文件
[root@com22 bin]# sh hdfs dfs -ls -R /flume/events/2015/01/28/15/55
-rw-r--r-- 3 root supergroup 12207 2015-01⑵8 15:56 /flume/events/2015/01/28/15/55/cmcc.1422431701282
[root@com22 bin]# sh hdfs dfs -rm /flume/events/2015/01/28/15/55/cmcc.1422431701282
15/03/05 14:28:00 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1440 minutes, Emptier interval = 0 minutes.
Moved: 'hdfs://com22.authentication:9000/flume/events/2015/01/28/15/55/cmcc.1422431701282' to trash at: hdfs://com22.authentication:9000/user/root/.Trash/Current
[root@com22 bin]#
入上图所示,设置回收站以后,每当你删除文件时,都会打印该文件被删除后放到哪里去了,如果你想恢复,mv就能够了
全部进程以下:
[root@com22 bin]# sh hdfs dfs -ls -R /flume/events/2015/01/28/15/55
[root@com22 bin]# sh hdfs dfs -ls -R /user/root/.Trash/Current
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01/28
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01/28/15
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01/28/15/55
-rw-r--r-- 3 root supergroup 12207 2015-01⑵8 15:56 /user/root/.Trash/Current/flume/events/2015/01/28/15/55/cmcc.1422431701282
[root@com22 bin]# sh hdfs dfs -mv /user/root/.Trash/Current/flume/events/2015/01/28/15/55/cmcc.1422431701282 /flume/events/2015/01/28/15/55
[root@com22 bin]# sh hdfs dfs -ls -R /user/root/.Trash/Current
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01/28
drwx------ - root supergroup 0 2015-03-05 14:28 /user/root/.Trash/Current/flume/events/2015/01/28/15
drwx------ - root supergroup 0 2015-03-05 14:31 /user/root/.Trash/Current/flume/events/2015/01/28/15/55
[root@com22 bin]# sh hdfs dfs -ls -R /flume/events/2015/01/28/15/55
-rw-r--r-- 3 root supergroup 12207 2015-01⑵8 15:56 /flume/events/2015/01/28/15/55/cmcc.1422431701282
[root@com22 bin]#