Backing Up and Restoring NameNode Metadata
This topic describes the steps for backing up and restoring NameNode metadata.
Backing Up NameNode Metadata
- Make a single backup of the VERSION file. This does not need to be backed up regularly as it does not change, but it is important since it contains the clusterID, along with other details.
- Use the following command to back up the NameNode metadata. It automatically determines the active NameNode, retrieves the current fsimage, and places it in the defined backup_dir.
$ hdfs dfsadmin -fetchImage backup_dir
On startup, the NameNode process reads the fsimage file and commits it to memory. If the JournalNodes are up and running, and there are edit files present, any edits newer than the fsimage are also applied. If the JournalNodes are unavailable, it is possible to lose any data transferred in the interim.
Restoring NameNode Metadata
- Add a new host to your Hadoop cluster.
- Add the NameNode role to the host. Make sure it has the same hostname as the original NameNode.
- Create a directory path for the NameNode name.dir (for example, /dfs/nn/current), ensuring that the permissions are set correctly.
- Copy the VERSION and latest fsimage file to the /dfs/nn/current directory.
- Run the following command to create the md5 file for the fsimage.
$ md5sum fsimage > fsimage.md5
- Start the NameNode process.