在hadoop中开启你的trash
hadoop fs -rmr /user 会把所有user目录下的所有目录和文件全都删除
这个命令运用的时候要慎重,他不会给你任何提示的。。。。
但是在hadoop中其实给了一个补救的措施,但是缺省情况下是不会开启的,这个其实就是trash机制,所以不需要提示
?
在core-site.xml中增加如下配置,表明rm后会在trash中保留多少分钟:
<property>
? <name>fs.trash.interval</name>
? <value>10080</value>
? <description>
????? Number of minutes between trash checkpoints. If zero, the trash feature is disabled
? </description>
</property>
很遗憾的是,hadoop的这个默认值是0,就是直接删除了
经过简单的测试,这个trash功能还是不错的,当rm后,它会move到当前文件夹下的.Trash目录下
如果你删除相同名字的一个文件或目录多次,则hadoop会自动在name后加上数字序列号
这样,如果你误删除后,就可以有选择的恢复文件了
hadoop fs -mkdir /user/oplog/test
hadoop fs -put *.txt? /user/oplog/test
hadoop fs -rmr /user/oplog/test
hadoop fs -ls /user/oplog/.Trash/Current/user/oplog
??? drwxr-xr-x?? oplog oplog????????? 0 2010-11-16 10:44 /user/oplog/.Trash/Current/user/oplog/test
hadoop fs -cp /user/oplog/.Trash/Current/user/oplog/test? ?/user/oplog/
hadoop fs -rmr /user/oplog/test
hadoop fs -ls /user/oplog/.Trash/Current/user/oplog
??? drwxr-xr-x?? oplog oplog????????? 0 2010-11-16 10:44 /user/oplog/.Trash/Current/user/oplog/test
??? drwxr-xr-x?? oplog oplog????????? 0 2010-11-16 10:47 /user/oplog/.Trash/Current/user/oplog/test.1
?