What do I do if a NameNode cannot be started after it is formatted?
If you format a NameNode in an E-MapReduce (EMR) cluster as the root user and then try to start it, the NameNode fails to start because the hdfs user does not have permissions on files owned by root.
Error message
ERROR namenode.NameNode: Failed to start namenode.
Cause
Running hadoop namenode -format as the root user creates NameNode metadata files owned by root. When the NameNode service starts, it runs as the hdfs user, which cannot read those files — causing the startup failure.
Solution
-
Stop all Hadoop Distributed File System (HDFS) components, including NameNode and DataNode.
-
Switch to the hdfs user and reformat the NameNode:
Warninghadoop namenode -formatdeletes all HDFS metadata. Run it only when HDFS contains no data you need to keep. In this scenario, the NameNode was already formatted as root with no data in HDFS, so it is safe to reformat.su hdfs [hdfs]$ hadoop namenode -formatIf permission errors occur on specific directories during formatting, grant the hdfs user the required permissions on those directories and retry.
-
Start the NameNode:
[hdfs]$ /usr/lib/hadoop-current/sbin/hadoop-daemon.sh start namenode -
Verify that HDFS is operating correctly:
[hdfs]$ hadoop fs -ls [hdfs]$ hadoop fs -put [hdfs]$ hadoop fs -get -
Run an MR job to confirm that YARN is working as expected.