1.在 core-site.xml 中添加:
<property>
<name>fs.trash.interval</name>
<value>4320</value>
</property>
fs.trash.interval参数的含义:
Number of minutes after which the checkpoint gets deleted. If zero,
the trash feature is disabled. This option may be configured both on
the server and the client. If trash is disabled server side then the
client side configuration is checked. If trash is enabled on the
server side then the value configured on the server is used and the
client configuration value is ignored.
不需要重启hdfs进行,直接生效
- 建立目录
需要首先建立 /user/YOUER_USER 目录
3.测试
[hadoop@hadoop01 hadoop]$ hdfs dfs -rm hdfs-site.xml
18/10/18 15:21:53 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform… using builtin-java classes where applicable
18/10/18 15:21:54 INFO fs.TrashPolicyDefault: Moved: 'hdfs://hadoop01:9000/user/hadoop/hdfs-site.xml' to trash at: hdfs://hadoop01:9000/user/hadoop/.Trash/Current/user/hadoop/hdfs-site.xml
可以看见文件进入了回收站