CDH5之Trash

参考: http://my.oschina.net/cloudcoder/blog/179381
      http://www.linuxidc.com/Linux/2012-02/55102.htm

查看CDH 的hdfs的配置,是否开启trash 及 保留时间:





测试:

点击(此处)折叠或打开

  1. 1.创建test.txt
  2. [root@sht-sgmhadoopnn-01 ~]# vi /tmp/test.txt
  3. 1
  4. 2
  5. 3
  6. 4
  7. 5

  8. 2.创建文件夹
  9. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -mkdir /testdir
  10. You have new mail in /var/spool/mail/root
  11. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /
  12. Found 4 items
  13. drwxr-xr-x - hdfs supergroup 0 2016-02-04 00:38 /system
  14. drwxr-xr-x - root supergroup 0 2016-02-19 08:17 /testdir
  15. drwxrwxrwt - hdfs supergroup 0 2016-02-10 16:04 /tmp
  16. drwxr-xr-x - hdfs supergroup 0 2016-02-10 16:02 /user

  17. 3.put 文件到hadoop
  18. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -put /tmp/test.txt /testdir
  19. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /testdir
  20. Found 1 items
  21. -rw-r--r-- 3 root supergroup 10 2016-02-19 08:18 /testdir/test.txt
  22. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -cat /testdir/test.txt
  23. 1
  24. 2
  25. 3
  26. 4
  27. 5
  28. You have mail in /var/spool/mail/root

  29. 4.删除文件夹testdir
  30. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -rm -r /testdir
  31. 16/02/19 08:27:05 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1440 minutes, Emptier interval = 0 minutes.
  32. Moved: 'hdfs://sgm-nameservice/testdir' to trash at: hdfs://sgm-nameservice/user/root/.Trash/Current
  33. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /
  34. Found 3 items
  35. drwxr-xr-x - hdfs supergroup 0 2016-02-04 00:38 /system
  36. drwxrwxrwt - hdfs supergroup 0 2016-02-10 16:04 /tmp
  37. drwxr-xr-x - hdfs supergroup 0 2016-02-10 16:02 /user
  38. You have mail in /var/spool/mail/root

  39. 5.查看回收站
  40. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /user/root/.Trash/Current
  41. Found 1 items
  42. drwxr-xr-x - root supergroup 0 2016-02-19 08:18 /user/root/.Trash/Current/testdir

  43. 6.恢复文件夹
  44. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -mv /user/root/.Trash/Current/testdir /
  45. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /
  46. Found 4 items
  47. drwxr-xr-x - hdfs supergroup 0 2016-02-04 00:38 /system
  48. drwxr-xr-x - root supergroup 0 2016-02-19 08:17 /testdir
  49. drwxrwxrwt - hdfs supergroup 0 2016-02-10 16:04 /tmp
  50. drwxr-xr-x - hdfs supergroup 0 2016-02-10 16:02 /user
  51. [root@sht-sgmhadoopnn-01 ~]# hadoop fs -cat /testdir/test.txt
  52. 1
  53. 2
  54. 3
  55. 4
  56. 5


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30089851/viewspace-1990991/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30089851/viewspace-1990991/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值