How do I correctly remove nodes in Hadoop?
hadoop
Solution
If you have not set dfs exclude file before, follow 1-3. Else start from 4.
- Shut down the NameNode.
- Set dfs.hosts.exclude to point to an empty exclude file.
- Restart NameNode.
- In the dfs exclude file, specify the nodes using the full hostname or IP or IP:port format.
- Do the same in mapred.exclude
- execute `bin/hadoop dfsadmin -refreshNodes`. This forces the NameNode to reread the exclude file and start the decommissioning process.
- execute `bin/hadoop mradmin -refreshNodes`
- 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.
- 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).
- If you do not plan to reintroduce the machine to the cluster, remove it from the include and exclude files.
To add a node as datanode and tasktracker see Hadoop FAQ page
EDIT : When a live node is to be removed from the cluster, what happens to the Job ?
The jobs running on a node to be de-commissioned would get affected as the tasks of the job scheduled on that node(s) would be marked as KILLED_UNCLEAN (for map and reduce tasks) or KILLED (for job setup and cleanup tasks). See line 4633 in JobTracker.java for details. The job will be informed to fail that task. Most of the time, Job tracker will reschedule execution. However, after many repeated failures it may instead decide to allow the entire job to fail or succeed. See line 2957 onwards in JobInProgress.java.
Problem
I'm running Hadoop 1.1.2 on a cluster with 10+ machines. I would like to nicely scale up and down, both for HDFS and MapReduce. By "nicely", I mean that I require that data not be lost (allow HDFS nodes to decomission), and nodes running a task finish before shutting down. I've noticed the datanode process dies once decomissioning is done, which is good. This is what I do to remove a node: - Add node to mapred.exclude - Add node to hdfs.exclude - `$ hadoop mradmin -refreshNodes` - `$ hadoop dfsadmin -refreshNodes` - `$ hadoop-daemon.sh stop tasktracker` To add the node back in (assuming it was removed like above), this is what I'm doing. - Remove from mapred.exclude - Remove from hdfs.exclude - `$ hadoop mradmin -refreshNodes` - `$ hadoop dfsadmin -refreshNodes` - `$ hadoop-daemon.sh start tasktracker` - `$ hadoop-daemon.sh start datanode` Is this the correct way to scale up and down "nicely"? When scaling down, I'm noticing job-duration rises sharply for certain unlucky jobs (since the tasks they had running on the removed node need to be re-scheduled).