CDH5之Trash

hackeruncle發表於2016-02-19
參考:http://my.oschina.net/cloudcoder/blog/179381
     

檢視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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章