I was using Cloudera's hadoop distribution, the version was cdh3u0, I guess and the OS was Fedora desktop edition 14. While I was trying to format the namenode with the usual command with which I formatted the namenode earlier, sudo -u hdfs hadoop namenode -format, I was not able to do that. Later I saw an article and found that the command that works is su - hdfs -c "hadoop namenode -format".
Next, you might not get namenode fomatted if the versions of the slaves and the master is not same. That includes the patch version too.
Furthermore, if you have incorrect permission for different directories used in hadoop data storage .i.e. namenode data, datanode data and mapred data , you might face problems. In one of my cases, while working with one of my colleagues, I was trying to format the namenode and it was not getting formatted saying, it could not write to the folder 'current' inside the namenode storage directory. I thought, that it might be a problem with the permission. I checked the permission for that namenode folder (/var/lib/hadoop-0.20/cache/hadoop in mycase) and found that it got root permission. I changed the permission to hdfs using chown hdfs:hdfs hadoop. That did the trick! I was able to format the namenode after that.
Next, you might not get namenode fomatted if the versions of the slaves and the master is not same. That includes the patch version too.
Furthermore, if you have incorrect permission for different directories used in hadoop data storage .i.e. namenode data, datanode data and mapred data , you might face problems. In one of my cases, while working with one of my colleagues, I was trying to format the namenode and it was not getting formatted saying, it could not write to the folder 'current' inside the namenode storage directory. I thought, that it might be a problem with the permission. I checked the permission for that namenode folder (/var/lib/hadoop-0.20/cache/hadoop in mycase) and found that it got root permission. I changed the permission to hdfs using chown hdfs:hdfs hadoop. That did the trick! I was able to format the namenode after that.
Thanks a lot for your post. I had a mix of all the problems mentioned above. After I read the post I managed to fix it and put it to work.
ReplyDeleteHi Joao,
ReplyDeleteYou are most welcome!
Feels great that the post helped you to solve your problems.
Please do comment in future here if you what to share with us other problems and their solutions.