在CentOS系统上进行HDFS数据恢复,可以参考以下几种方法:
core-site.xml配置文件中添加如下配置:<property>
    <name>fs.trash.interval</name>
    <value>120</value>
</property>
<property>
    <name>fs.trash.checkpoint.interval</name>
    <value>120</value>
</property>
这会启用回收站并将检查间隔设置为120分钟。.Trash/Current目录下。可以通过以下命令将文件从回收站中恢复:hdfs dfs -cp /user/username/.Trash/Current/deleted_file /path/to/restore
hdfs fs -allowSnapshot /testhdfs
hdfs fs -put test.txt /testhdfs
hdfs fs -createSnapshot /testhdfs/import_data
hdfs fs -rmr /testhdfs/test.txt
hdfs fs -cp /testhdfs/.snapshot/import_data/test.txt /path/to/restore
sudo systemctl stop hadoop-namenodes
sudo systemctl stop hadoop-datanode
fsimage文件,并将其拷贝到新集群的NameNode上。sudo yum install extundelete
sudo extundelete /path/to/hdfs/directory --restore-file path/to/deleted/file
sudo yum install testdisk
sudo testdisk
请根据实际情况选择合适的恢复方法,并在操作前仔细阅读相关文档,以确保数据能够安全恢复。