CDH5之Trash

简介: 参考:http://my.oschina.net/cloudcoder/blog/179381      http://www.linuxidc.com/Linux/2012-02/55102.
参考: 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


目录
相关文章
|
3月前
mkdir、rm、cp、mv命令
mkdir、rm、cp、mv命令
42 0
|
4月前
|
SQL Linux Ruby
linux(十)目录相关命令ll、pwd、cd(2)
这里有两种情况需要做一下区分: 1):逗号相隔的字符串 ruby 复制代码
39 0
|
4月前
|
SQL Linux Shell
linux(十)目录相关命令ll、pwd、cd(1)
Linux的常用基本命令,大概先了解下他目录相关的命令,linux的目录其实就是windows下的文件夹,文件夹,是windows系统引入的一个概念。这个大概了解一下。
28 0
|
5月前
|
Linux
初学[linux]基础命令“ls,cd,pwd,mkdir“
初学[linux]基础命令“ls,cd,pwd,mkdir“
86 1
全网首发:解决办法,/bin/ant: 1: cd: can‘t cd to /bin/../share/ant/bin/..
全网首发:解决办法,/bin/ant: 1: cd: can‘t cd to /bin/../share/ant/bin/..
722 0
ls -al /usr/lib | grep libevent --- 查看libevent是否已安装
ls -al /usr/lib | grep libevent --- 查看libevent是否已安装
217 0