hadoop文件误删恢复(官网自带回收站设置)

https://hadoop.apache.org/docs/r2.7.4/hadoop-project-dist/hadoop-common/core-default.xml

官网的配置释义

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.

翻译:

分钟数,在此分钟之后,检查点将被删除。 如果为零,则禁用垃圾桶功能。 可以在服务器和客户端上都配置此选项。 如果在服务器端禁用了垃圾箱,则将检查客户端配置。 如果在服务器端启用了垃圾回收,那么将使用服务器上配置的值,而忽略客户端配置值。

配置文件/etc/hadoop/core-site.xml,在其中添加如下信息:
<property>
    <name>fs.trash.interval</name>
    <value>10080</value>
    <description>
      Number of minutes between trash checkpoints. If zero, the trash feature is disabled.
    </description>
</property>

回收站时间为一周(超过则用这个方法无法恢复)
其中10080代表分钟数,即代表删除的文件或目录在".Trash"(回收站)中保留的时间,可自行设置。保存即可。
hdfs dfs -lsr 时暂时看不到.Trash,再删除某个文件或者目录之后, 再次用lsr即可看到所在目录下的回收站.Trash已经建好:

上述可以看见删除的文件

如果恢复可以找到对应删除的文件执行

hdfs dfs -mv /hdfs目录/.Trash/对应的删除文件  /hdfs恢复路径

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值