Hadoop回收站trash


Hadoop回收站trash,默認是關閉的。
習慣了window的同學,建議最好還是把它提前開開,否則誤操作的時候,就欲哭無淚了

1.修改conf/core-site.xml,增加

<property> 
<name>fs.trash.interval</name> 
<value>1440</value> 
<description>Number of minutes between trash checkpoints. 
If zero, the trash feature is disabled. 
</description> 
</property>

 

默認是0.單位分鍾。這里我設置的是1天(60*24)
刪除數據rm后,會將數據move到當前文件夾下的.Trash目錄

2.測試
1)新建目錄input

hadoop/bin/hadoop fs -mkdir input

 

2)上傳文件

root@master:/data/soft# hadoop/bin/hadoop fs -copyFromLocal /data/soft/file0* input


3)刪除目錄input

[root@master data]# hadoop fs -rmr input 
Moved to trash: hdfs://master:9000/user/root/input


4)參看當前目錄

[root@master data]# hadoop fs -ls 
Found 2 items 
drwxr-xr-x - root supergroup 0 2011-02-12 22:17 /user/root/.Trash

 

發現input刪除,多了一個目錄.Trash

5)恢復剛剛刪除的目錄

[root@master data]# hadoop fs -mv /user/root/.Trash/Current/user/root/input /user/root/input


6)檢查恢復的數據

[root@master data]# hadoop fs -ls input 
Found 2 items 
-rw-r--r-- 3 root supergroup 22 2011-02-12 17:40 /user/root/input/file01 
-rw-r--r-- 3 root supergroup 28 2011-02-12 17:40 /user/root/input/file02

 


6)刪除.Trash目錄(清理垃圾)

[root@master data]# hadoop fs -rmr .Trash 
Deleted hdfs://master:9000/user/root/.Trash

轉自 http://running.iteye.com/blog/904536


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM