Mastering Hadoop 3
上QQ阅读APP看书,第一时间看更新

Admin commands

The admin is responsible for maintaining clusters and continuously checking the reports of DataNode. There are a few commands that the admin uses frequently for a File System. Admin commands start with hadoop dfsadmin command.

-report: This command is used to generate a report of DataNodes, such as basic File System information, statistics about used space and free space, and so on. You can also use options to filter live or dead DataNodes by using the -live and -dead options:

hdfs dfsadmin -report -live 
hdfs dfsadmin -report -dead

The admin uses this command to check which DataNode has higher or lower uses than average cluster uses to ascertain whether any node needs to be excluded or included in a balancer operation or to check whether a new node needs to be added. 

- safemode: This is a maintenance state of NameNode, during which NameNode doesn't allow any changes to the FileSystem.

In the safemode state, the HDFS cluster is read-only and it doesn't replicate or delete blocks. Generally, when nameNode starts, it automatically goes into safemode and does the following:

  • Loads fsimage and edits the log into memory
  • Applies edit log changes to fsimage, which gives a new FileSystem namespace
  • Finally, it receives a block report from the DataNode, which contains information about the block's location

The admin can also enter the safemode state manually or check the safemode status. Manually entering NameNode into safemode does not allow NameNode to leave safemode automatically—you must explicitly leave it, as shown in the following command:

hdfs dfsadmin -safemode enter/get/leave

There are hundreds of commands available that can be used with HDFS, but covering all of these commands is outside the scope of this book. You can refer to the HDFS documentation to understand the uses of all the commands.