时间:2021-07-01 10:21:17 帮助过:7人阅读
Hadoop 回收站的trash 默认是 关闭的, 你只要在 conf/core-site.xml 里面开启就可以了 View Code PHP ? hadoop.tmp.dir /usr/hadoop/tmp A base for other temporary directories.? fs.default.name hdfs://192.168.1.192:9000?!--下面的代码就是开启hadoop
Hadoop 回收站的trash 默认是 关闭的, 你只要在 conf/core-site.xml 里面开启就可以了
View Code PHP
? hadoop.tmp.dir /usr/hadoop/tmp A base for other temporary directories. ? fs.default.name hdfs://192.168.1.192:9000 ? ? fs.trash.interval 1440 Number of minutes between trash checkpoints. If zero, the trash feature is disabled. ?
1440 是设置回收站保存的时间, 单位分钟 这里我设置一天:1440 = 60*24
2、测试回收站功能
看下我dfs 下面的文件
View Code PHP
[hadoop@master conf]$ hadoop fs -ls Found 3 items drwxr-xr-x - hadoop supergroup 0 2013-01-13 17:00 /user/hadoop/.Trash drwxr-xr-x - hadoop supergroup 0 2013-01-10 21:02 /user/hadoop/intoday drwxr-xr-x - hadoop supergroup 0 2013-01-10 21:03 /user/hadoop/outtoday [hadoop@master conf]$ hadoop fs -ls intoday Found 2 items -rw-r--r-- 1 hadoop supergroup 2 2013-01-10 21:02 /user/hadoop/intoday/file1.txt -rw-r--r-- 1 hadoop supergroup 2 2013-01-10 21:02 /user/hadoop/intoday/file2.txt [hadoop@master conf]$
可以看到indoday 里面有file1.txt 跟file2.txt, 下面把intoday 这个目录删除
View Code PHP
[hadoop@master conf]$ hadoop fs -rmr intoday Moved to trash: hdfs://192.168.1.192:9000/user/hadoop/intoday [hadoop@master conf]$
提示Moved to trash ,说明文件已经删除到回收站了
看看回收站里面有没有
View Code PHP
[hadoop@master conf]$ hadoop fs -ls Found 2 items drwxr-xr-x - hadoop supergroup 0 2013-01-13 17:10 /user/hadoop/.Trash drwxr-xr-x - hadoop supergroup 0 2013-01-10 21:03 /user/hadoop/outtoday [hadoop@master conf]$ hadoop fs -ls /user/hadoop/.Trash Found 2 items drwxr-xr-x - hadoop supergroup 0 2013-01-13 16:45 /user/hadoop/.Trash/1301131700 drwxr-xr-x - hadoop supergroup 0 2013-01-13 17:10 /user/hadoop/.Trash/Current //这个文件就是回收站里面的文件 , 你可以用 -ls 具体查看
3 删除了当然要回复,下面恢复下回收站的文件
View Code PHP
[hadoop@master conf]$ hadoop fs -mv .Trash/Current/user/hadoop/intoday intoday [hadoop@master conf]$ hadoop fs -ls Found 3 items drwxr-xr-x - hadoop supergroup 0 2013-01-13 17:10 /user/hadoop/.Trash drwxr-xr-x - hadoop supergroup 0 2013-01-10 21:02 /user/hadoop/intoday drwxr-xr-x - hadoop supergroup 0 2013-01-10 21:03 /user/hadoop/outtoday [hadoop@master conf]$ hadoop fs -ls intoday Found 2 items -rw-r--r-- 1 hadoop supergroup 2 2013-01-10 21:02 /user/hadoop/intoday/file1.txt -rw-r--r-- 1 hadoop supergroup 2 2013-01-10 21:02 /user/hadoop/intoday/file2.txt
可以看到 intoday 文件已经回复 ,file1.txt file2.txt 也已经恢复
4、清空回收站命令:hdfs dfs -expunge
文章转载请注明地址: hadoop学习笔记 – 回收站机制的开启 http://www.wangzhibo.com/hadoop/1488.html
原文地址:hadoop学习笔记 – 回收站机制的开启, 感谢原作者分享。