The Datanodes periodically update the Namenode about its presence or any changes in the blocks. The default Datanode heartbeat time is three seconds. But this does not mean that if a Datanode does not send a heartbeat for, say, 10 seconds, that the node will be marked dead.
In this recipe, we will look at how a heartbeat is configured and the parameters that play a role in its function.
Getting ready
You have a running cluster, and the user is familiar with Datanode communication with Namenode.
How to do it...
ssh to Namenode and edit the hdfs-site.xml file to add the following property to it:
Copy hdfs-site.xml across all nodes in the cluster.
Restart HDFS daemons across nodes for the property to take effect:
$ stop-dfs.sh$ start-dfs.sh
How it works...
These parameters are default parameters, which control how often the Datanodes send updates and when a Datanode will expire or be marked dead. Remember that dfs.heartbeat.interval is in seconds and the dfs.heartbeat.interval parameter is in milliseconds.
So, when a Datanode is dead, for any reason, it will take 10 minutes and 30 seconds for Namenode to mark it as dead. This is not true whenever a graceful removal of a node is performed, as discussed in Chapter 1, Hadoop Architecture and Deployment. There are a lot of factors that govern when a Namenode marks a Datanode as dead and how quickly it does this. But, if the user simply shuts down a Datanode and executes hdfs dfsadmin –report, the node will still be seen there. The formula that defines when a Datanode is marked as stale is as follows:
Datanode Removal time = (2 x dfs.namenode.heartbeat.recheck-interval ) + (10 X dfs.heartbeat.interval