官术网_书友最值得收藏!

Recycle or trash bin configuration

There will also be cases where we need to restore an accidently deleted file or directory. This may be due to a user error or some archiving policy that cleans data periodically.

For such situations, we can configure the recycle bin so that the deleted files can be restored for a specified amount of time. In this recipe, we will see that this can be configured.

Getting ready

This recipe shows the steps needed to edit the configuration file and add new parameters to the file to enable trash in the Hadoop cluster.

How to do it...

  1. ssh to Namenode and edit the core-site.xml file to add the following property to it:
    <property>
    <name>fs.trash.interval</name>
    <value>10080</value>
    </property>
  2. The fs.trash.interval parameter defines the time in minutes after which the checkpoint will be deleted.
  3. Restart the namenode daemon for the property to take effect:
    $ hadoop-daemons.sh stop namenode
    $ hadoop-daemons.sh start namenode
    
  4. Once trash is enabled, delete any unimportant files, as shown in the following screenshot. You will see a different message--rather than saying deleted, it says moved to trash:
    How to do it...
  5. The deleted file can be restored by using the following command:
    $ hadoop fs -cp /user/hadoop/.Trash/Current/input/new.txt /input/
    

How it works...

Any deleted data is moved to the .Trash directory under the home of the user who executed the command. Every time the check pointer runs, it creates a new checkpoint out of current and removes any checkpoints created more than fs.trash.interval minutes ago.

There's more...

In addition to the preceding method, there is a fs.trash.checkpoint.interval parameter that defines the number of minutes between checkpoints.

主站蜘蛛池模板: 孟村| 故城县| 北流市| 东阳市| 大同县| 大悟县| 新密市| 收藏| 雅安市| 玛纳斯县| 衡水市| 左贡县| 泸溪县| 屯昌县| 金门县| 柘荣县| 潞西市| 凤台县| 贵南县| 绥宁县| 汾西县| 三明市| 延川县| 阿拉善左旗| 石渠县| 伽师县| 鄂托克前旗| 永吉县| 大洼县| 虞城县| 邵阳市| 昭觉县| 丹江口市| 清镇市| 宜阳县| 西丰县| 西青区| 加查县| 元江| 土默特左旗| 仲巴县|