How to add a new HDFS NameNode metadata directory to an existing cluster?

Posted on

We have a running HDFS cluster. Currently, the NameNode metadata data directory has only one directory configured in hdfs-site.xml:

    <description>NameNode directory for namespace and transaction logs storage.</description>

We would like to add a new directory for to make replicas of the metadata on a separated disk for higher data reliability.

How to safely add the new directory?

Backup first as the NameNode metadata directory contains critical data for the HDFS cluster.

Then following these steps.

First, shutdown the NameNode.

Second, copy the files from the old NameNode metadata directory to the new metadata directory. Such as to /home/hadoop/hdfs2,

cp -r /home/hadoop/hdfs/* /home/hadoop/hdfs2/

Third, add the new metadata directory to hdfs-site.xml:

    <value>file:///home/hadoop/hdfs/, file:///home/hadoop/hdfs2/</value>
    <description>NameNode directory for namespace and transaction logs storage.</description>

Last, restart the NameNode.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts