hadoophdfsnamenodedatanode

Hadoop : swap DataNode & NameNode without losing any HDFS data


I have a cluster of 5 machines:

I want to change my current NameNode with a DataNode without losing the data stored in HDFS, so my cluster could become:

Does someone know a simple way to do that?

Thank you very much


Solution

    1. Decomission 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 same.
    7. Now start the cluster by starting 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.