大数据开发之Hadoop篇----hdfs垃圾回收机制配置

本文介绍如何在HDFS中启用垃圾回收机制,通过配置fs.trash.interval和fs.trash.checkpoint.interval参数来设定垃圾回收的时间间隔和检查点。详细解释了参数意义及生产环境中推荐的设置值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

其实要启动hdfs上的垃圾回收机制只需要配置两个参数就可以了,也是在core-site.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.

当fs.trash.interval设置为0的时候是禁用了垃圾回收机制的功能的,而其设置是按分钟来的,现在我们设置为1440,一天的时间,而生产上我们一般是设置成7天或者14天这样子的。

而第二个参数fs.trash.checkpoint.interval的意思是:Number of minutes between trash checkpoints. Should be smaller or equal to fs.trash.interval. If zero, the value is set to the value of fs.trash.interval. Every time the checkpointer runs it creates a new checkpoint out of current and removes checkpoints created more than fs.trash.interval minutes ago.

意味这两个检查点之间的分钟数,一般是要少于或者等于fs.trash.interval的,如果设置为0的话就等同与fs.trash.interval,所以生产上我们就直接设置为0。

我现在试下删除一个文件

尤其最后一句话,删除只是把文件移动到了一个路径,这个路径在:

hdfs://hadoop001:9000/user/hadoop/.Trash/Current/user/hadoop/LICENSE.txt。这个就是回收站的路径了,想恢复你直接mv回去就行了。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值