Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use HDFS to recover deleted files

Shulou Source: shulou.com Published: 2022-06-01 15:28:01 10月01日 Update

This article mainly explains "how to use HDFS to recover deleted files". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use HDFS to recover deleted files.

Hadoop has a "garbage collection bin" function to recover files that have been deleted in the past. If a file has been deleted multiple times, you can also restore the deleted file. This feature is disabled by default. If you want to enable it, you need to add the following configuration in the $HADOOP_HOME/etc/hadoop/core-site.xml file:

Fs.trash.interval 10

The above configuration means: Hadoop will set up a Recycle Bin, which will be emptied every 10 minutes.

If you delete the same file or directory multiple times in a recycling cycle, the file you deleted each time will be saved in different versions within Trash. This means that you can restore files that have been deleted at some point.

For example:

Time point action Trash content 12:40 Recycle Bin empty empty12:41 delete fruit.datafruit.data12:42 re-upload fruit.data and delete fruit.datafruit.data,fruit.data144635293518612:45 re-upload fruit.data and delete fruit.datafruit.data,fruit.data1446352935186,fruit.data144635310039012:50 Recycle Bin empty empty

According to the above table, the second time you delete friut.data at 12:41, fruit. ‍ data1446352935186 ‍ appears in the Recycle Bin, followed by a string of numbers that are the timestamp of the moment you deleted it. Then we can restore files deleted at 12:41 or 12:45 before the garbage collection bin is emptied.

Combined with the use of hive, there are generally many scheduled tasks to insert updated data into hive, so there will be many versions of a certain table in .Trash. If you want to view the data at a certain time, you only need to restore the data at that time in Trash, which is especially useful for accidental deletion.

At this point, I believe you have a deeper understanding of "how to use HDFS to recover deleted files". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: File Recycle Bin time content data moment again function garbage version Learning configuration practical Deep list above tasks examples interests actions available in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL macOS Docker Apple