NameNode records the metadata of all the files stored in the cluster, such as location of blocks stored, size of the files, permissions, hierarchy, etc. There are two files associated with the metadata:
- FsImage: Contains the complete state of the file system namespace since the start of the NameNode.
- EditLogs: It contains all the recent modifications made to the file system with respect to the most recent FsImage.
If a file is deleted in HDFS, the NameNode will immediately record this in the EditLog.
The Secondary NameNode is one which constantly reads all the file systems and metadata from the RAM of the NameNode and writes it into the hard disk or the file system. It is responsible for combining the EditLogs with FsImage from the NameNode.
Secondary NameNode downloads the EditLogs from the NameNode at regular intervals and applies to FsImage. The new FsImage is copied back to the NameNode, which is used whenever the NameNode is started the next time.