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


目录
相关文章
|
6月前
mkdir、rm、cp、mv命令
mkdir、rm、cp、mv命令
85 0
|
4月前
|
Linux
创建目录mkdir,语法​mkdir [-p] Linux路径​,mkdir ~/test3在home下创建,mkdir ./x 当前目录创建 mkdir /home/xx,mkdir -p 通,必须
创建目录mkdir,语法​mkdir [-p] Linux路径​,mkdir ~/test3在home下创建,mkdir ./x 当前目录创建 mkdir /home/xx,mkdir -p 通,必须
|
Linux
初学[linux]基础命令“ls,cd,pwd,mkdir“
初学[linux]基础命令“ls,cd,pwd,mkdir“
123 1
|
Java Linux Nacos
[root@CentOS7 bin]# ./startup.sh -p 3333 which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbi
[root@CentOS7 bin]# ./startup.sh -p 3333 which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbi
ls -al /usr/lib | grep libevent --- 查看libevent是否已安装
ls -al /usr/lib | grep libevent --- 查看libevent是否已安装
253 0
|
SQL 分布式计算 Hadoop
|
Web App开发 关系型数据库 MySQL