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命令
40 0
|
4月前
|
SQL Linux Ruby
linux(十)目录相关命令ll、pwd、cd(2)
这里有两种情况需要做一下区分: 1):逗号相隔的字符串 ruby 复制代码
38 0
|
4月前
|
SQL Linux Shell
linux(十)目录相关命令ll、pwd、cd(1)
Linux的常用基本命令,大概先了解下他目录相关的命令,linux的目录其实就是windows下的文件夹,文件夹,是windows系统引入的一个概念。这个大概了解一下。
28 0
|
数据可视化 安全 Linux
Linux目录和文件管理:mkdir、touch、cp、mv、rm
1 创建 文件名最长255个字节 包括路径在内文件名称最长4095个字节 除了斜杠和NULL,所有字符都有效.但使用特殊字符的目录名和文件不推荐使用,有些字符需要用引 号来引用
248 0
|
开发工具
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(五)
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(五)
145 0
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(五)
|
开发工具
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(三)
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(三)
106 0
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(三)
|
Linux 开发工具 虚拟化
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(二)
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(二)
127 0
LINUX02_概述、文件系统详解、vim、cd、ls、mkdir、touch、rm、cp、less、tail、head、find、locate、打包或解压tar(二)