You want to take out some data nodes from your cluster, what is the graceful way to remove nodes without corrupting file system. On a large cluster removing one or two data-nodes will not lead to any data loss, because name-node will replicate their blocks as long as it will detect that the nodes are dead. With a large number of nodes getting removed or dying the probability of losing data is higher.

Hadoop offers the decommission feature to retire a set of existing data-nodes. The nodes to be retired should be included into the exclude file, and the exclude file name should be specified as a configuration parameter dfs.hosts.exclude. This file should have been specified during namenode startup. It could be a zero length file. You must use the full hostname, ip or ip:port format in this file. Then the shell command

bin/hadoop dfsadmin -refreshNodes

should be called, which forces the name-node to re-read the exclude file and start the decommission process.

Decommission does not happen momentarily since it requires replication of potentially a large number of blocks and we do not want the cluster to be overwhelmed with just this one job. The decommission progress can be monitored on the name-node Web UI. Until all blocks are replicated the node will be in "Decommission In Progress" state. When decommission is done the state will change to "Decommissioned". The nodes can be removed whenever decommission is finished.

The decommission process can be terminated at any time by editing the configuration or the exclude files and repeating the -refreshNodes command.
Steps,
If you have not set dfs exclude file before, follow 1-3. Else start from 4.

  1.     Shut down the NameNode.
  2.     Set dfs.hosts.exclude to point to an empty exclude file. /conf/hdfs-site.xml:

    dfs.hosts.exclude
    /usr/local/hadoop/hadoop-0.20.2/conf/exclude

    Add hosts in exclude file:
    Format will be host or IP:Port
  3.     Restart NameNode.
  4.     In the dfs exclude file, specify the nodes using the full hostname or IP or IP:port format.
  5.     Do the same in mapred.exclude
  6.     execute bin/hadoop dfsadmin -refreshNodes. This forces the NameNode to reread the exclude file and start the decommissioning process.
  7.     execute bin/hadoop mradmin -refreshNodes
  8.     Monitor the NameNode and JobTracker web UI and confirm the decommission process is in progress. It can take a few seconds to update. Messages like "Decommission complete for node XXXX.XXXX.X.XX:XXXXX" will appear in the NameNode log files when it finishes decommissioning, at which point you can remove the nodes from the cluster.
  9.     When the process has completed, the namenode UI will list the datanode as decommissioned. The Jobtracker page will show the updated number of active nodes. Run bin/hadoop dfsadmin -report to verify. Stop the datanode and tasktracker process on the excluded node(s).
  10.  If you do not plan to reintroduce the machine to the cluster, remove it from the include and exclude files.
Previous Post Next Post