Hadoop safemode recovery – taking too long!
January 12, 2017DataNode process killed due to Incompatible clusterIDs error
January 19, 2017FSNamesystem initialization failed
FSNamesystem initialization failed is a common error Hadoop users gets especially if there are trying to set up of a Hadoop cluster for the very first time.
13/05/23 04:11:37 ERROR namenode.FSNamesystem: FSNamesystem initialization failed. java.io.IOException: NameNode is not formatted. at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:330) at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:100) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:411)
Check the values for below 2 properties in hdfs-site.xml
<property> <name>dfs.namenode.name.dir</name> <value>file:///data/1/dfs/nn</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///data/1/dfs/dn</value> </property>
Directory location specified in dfs.namenode.name.dir must present in NameNode’s local filesystem. Directory location specified in dfs.datanode.data.dir must present in all DataNodes’ local filesystem.
If you don’t see them present. Stop all running Hadoop process. Create the missing directories in NameNode and DataNodes respectively. Make sure the folders are permissioned properly. Use the below commands for reference.
On NameNode
sudo mkdir -p /data/1/dfs/nn sudo chown -R hdfs:hdfs /data/1/dfs/nn sudo chmod 700 /data/1/dfs/nn
On DataNodes
sudo mkdir -p /data/1/dfs/dn sudo chown -R hdfs:hdfs /data/1/dfs/dn
Once the directories are created, format the NameNode by executing the below command in the NameNode.
sudo -u hdfs hdfs namenode -format
Now you are ready to start the NameNode. Once the NameNode is started, check the logs and make sure you don’t see any erros. Once NameNode is successfully started, start all the DataNodes.