Hadoop Stores its metadata in memory as well as physical files. These physical files are fsimage and editlog. There is a utility in hadoop to fetch the fsimage. FetchImage is a command used to fetch the fsimage without picking the file physically from the namenode. This command will stream the fsimage to the node where we trigger this command and save this as a file.
The complete command is shown below.
hadoop dfsadmin -fetchImage <local directory> Eg: mkdir fsimage hadoop dfsadmin -fetchImage fsimage
This command will save the fsimage in the local directory fsimage. This command should be executed from the hadoop admin.
You may get an error while triggering this command. “Only Namenode, Secondary Namenode, and administrators may access this servlet”.
This command is restricted to a list of users defined by the property “dfs.cluster.administrators”. This is a property in hdfs-site.xml. If you are using cloudera manager 4.x, this property is not set by default. In Cloudera Manager 5, this property is set to hdfs by default. So the clusters managed by Cloudera Manager 5.x, this command can be triggered by hdfs user from any of the nodes without setting any property.
Note: This property is not restricted to Cloudera Hadoop. All distribution of hadoop has this feature. So no need to worry about Cloudera Manager and all.
We can set the list of users or groups who has access to execute this command from any node by setting the following property in hdfs-site.xml
<property> <name>dfs.cluster.administrators</name> <value>amal,sree,sahad,user1,user2,user3,group1,group2,group3</value> </property>
If this property is not set, you may get the error “Only Namenode, Secondary Namenode, and administrators may access this servlet” and you will not be able to fetch the fsimage.