60 | Big Data Simplied
have a default backup location on the local file system of the NameNode. You can also
configure this backup to be on a remote disk. In fact, you can also specify multiple backup
locations. Each backup can be on a different host, thereby ensuring that the NameNode
data is never lost. However, using metadata files as a backup strategy, is not always an opti-
mum solution. Merging these two files, the FsImage and edits, is a very resource-intensive
operation. Hadoop clusters tend to be long running. They are not meant to be restarted
often. It can have thousands of jobs, where all of them manipulating the file system. Thus,
the log information in edits will be very large, and the combination of FsImage and edits is
not trivial.
b. Using the secondary NameNode: It is a much easier way to bring back the system online.
The secondary NameNode is an exact backup of the NameNode.
The original NameNode has its FsImage and edits file, the secondary NameNode copies over
the FsImage and edits from the original NameNode, and it runs on a completely different
machine.
The secondary NameNode and the original NameNode sync up their information to make
sure that they are up to date with each other, where it is called checkpointing. After the
secondary NameNode gets its copy of the metadata files, it merges these two files together
to get an updated FsImage. It applies every transaction, every file edit in the edits log to the
FsImage to get an updated FsImage.
This updated FsImage is then copied back to the NameNode, so the NameNode will replace
its FsImage from the checkpointed FsImage on the secondary NameNode. The edits files on
both these machines are reset to empty, and it does not contain any logs, as the FsImage is now
up to date with all edits. At this point, both the NameNode and the secondary NameNode are
in sync and up to date.
Checkpointing of this kind is done at a specific frequency, which is configurable. In case of
NameNode failure, the secondary NameNode is simply promoted to be the NameNode and
a new machine on the cluster is made the secondary NameNode.
FIGURE 3.17 Fault tolerant of NameNode with secondary NameNode
Secondary
NameNode
Active
NameNode
Standby
NameNode
FsImageFsImage
Query for edit logs
Copy the updated fsimage back
to NameNode for future use
High availability
of NameNode
edit logs to sync with
HDFS metadata in
NameNode
M03 Big Data Simplified XXXX 01.indd 60 5/10/2019 9:57:33 AM