Hadoop : swap DataNode & NameNode without losing any HDFS data

To Swap datanode and Namenode to deploy a new cluster or migrate the namenode role to new node, we can follow below points:



  1. Decommission data node where namenode will be moved.
  2. Stop the cluster.
  3. Create a tar of dfs.name.dir from current namenode.
  4. Copy all Hadoop config files from current NN to target NN.
  5. Replace the name/IP of target namenode by modifying core-site.xml.
  6. Restore tarball of dfs.name.dir. Make sure that full path is the same.
  7. Now start the cluster by starting a new namenode and one less datanode.
  8. Verify that everything is working perfectly.
  9. Add old namenode as datanode by configuring it as datanode.
  10. I would suggest to uninstall and then install Hadoop on both the nodes so that previous configuration does not cause any problem.

Comments