共计 1934 个字符,预计需要花费 5 分钟才能阅读完成。
本文丸趣 TV 小编为大家详细介绍“怎么查看 CDH5 是否开启 Trash”,内容详细,步骤清晰,细节处理妥当,希望这篇“怎么查看 CDH5 是否开启 Trash”文章能帮助大家解决疑惑,下面跟着丸趣 TV 小编的思路慢慢深入,一起来学习新知识吧。
查看 CDH 的 hdfs 的配置, 是否开启 trash 及 保留时间:
测试:
1. 创建 test.txt
[root@sht-sgmhadoopnn-01 ~]# vi /tmp/test.txt
2. 创建文件夹
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -mkdir /testdir
You have new mail in /var/spool/mail/root
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /
Found 4 items
drwxr-xr-x – hdfs supergroup 0 2016-02-04 00:38 /system
drwxr-xr-x – root supergroup 0 2016-02-19 08:17 /testdir
drwxrwxrwt – hdfs supergroup 0 2016-02-10 16:04 /tmp
drwxr-xr-x – hdfs supergroup 0 2016-02-10 16:02 /user
3.put 文件到 hadoop
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -put /tmp/test.txt /testdir
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /testdir
Found 1 items
-rw-r–r– 3 root supergroup 10 2016-02-19 08:18 /testdir/test.txt
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -cat /testdir/test.txt
You have mail in /var/spool/mail/root
4. 删除文件夹 testdir
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -rm -r /testdir
16/02/19 08:27:05 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1440 minutes, Emptier interval = 0 minutes.
Moved: hdfs://sgm-nameservice/testdir to trash at: hdfs://sgm-nameservice/user/root/.Trash/Current
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /
Found 3 items
drwxr-xr-x – hdfs supergroup 0 2016-02-04 00:38 /system
drwxrwxrwt – hdfs supergroup 0 2016-02-10 16:04 /tmp
drwxr-xr-x – hdfs supergroup 0 2016-02-10 16:02 /user
You have mail in /var/spool/mail/root
5. 查看回收站
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /user/root/.Trash/Current
Found 1 items
drwxr-xr-x – root supergroup 0 2016-02-19 08:18 /user/root/.Trash/Current/testdir
6. 恢复文件夹
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -mv /user/root/.Trash/Current/testdir /
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -ls /
Found 4 items
drwxr-xr-x – hdfs supergroup 0 2016-02-04 00:38 /system
drwxr-xr-x – root supergroup 0 2016-02-19 08:17 /testdir
drwxrwxrwt – hdfs supergroup 0 2016-02-10 16:04 /tmp
drwxr-xr-x – hdfs supergroup 0 2016-02-10 16:02 /user
[root@sht-sgmhadoopnn-01 ~]# hadoop fs -cat /testdir/test.txt
读到这里,这篇“怎么查看 CDH5 是否开启 Trash”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注丸趣 TV 行业资讯频道。