HDFS Commands Guide

Overview

All HDFS commands are invoked by the bin/hdfs script. Running the hdfs script without any arguments prints the description for all commands.

Usage: hdfs [SHELL_OPTIONS] COMMAND [GENERIC_OPTIONS] [COMMAND_OPTIONS]

Hadoop has an option parsing framework that employs parsing generic options as well as running classes.

COMMAND_OPTIONSDescription
SHELL_OPTIONSThe common set of shell options. These are documented on the Commands Manual page.
GENERIC_OPTIONSThe common set of options supported by multiple commands. See the Hadoop Commands Manual for more information.
COMMAND COMMAND_OPTIONSVarious commands with their options are described in the following sections. The commands have been grouped into User Commands and Administration Commands.

User Commands

Commands useful for users of a hadoop cluster.

classpath

Usage: hdfs classpath [--glob |--jar <path> |-h |--help]

COMMAND_OPTIONDescription
--globexpand wildcards
--jar pathwrite classpath as manifest in jar named path
-h, --helpprint help

Prints the class path needed to get the Hadoop jar and the required libraries. If called without arguments, then prints the classpath set up by the command scripts, which is likely to contain wildcards in the classpath entries. Additional options print the classpath after wildcard expansion or write the classpath into the manifest of a jar file. The latter is useful in environments where wildcards cannot be used and the expanded classpath exceeds the maximum supported command line length.

dfs

Usage: hdfs dfs [COMMAND [COMMAND_OPTIONS]]

Run a filesystem command on the file system supported in Hadoop. The various COMMAND_OPTIONS can be found at File System Shell Guide.

envvars

Usage: hdfs envvars

display computed Hadoop environment variables.

fetchdt

Usage: hdfs fetchdt <opts> <token_file_path>

COMMAND_OPTIONDescription
--webservice NN_UrlUrl to contact NN on (starts with http or https)
--renewer nameName of the delegation token renewer
--cancelCancel the delegation token
--renewRenew the delegation token. Delegation token must have been fetched using the --renewer name option.
--printPrint the delegation token
token_file_pathFile path to store the token into.

Gets Delegation Token from a NameNode. See fetchdt for more info.

fsck

Usage:

   hdfs fsck <path>
          [-list-corruptfileblocks |
          [-move | -delete | -openforwrite]
          [-files [-blocks [-locations | -racks | -replicaDetails | -upgradedomains]]]
          [-includeSnapshots] [-showprogress]
          [-storagepolicies] [-maintenance]
          [-blockId <blk_Id>]
COMMAND_OPTIONDescription
pathStart checking from this path.
-deleteDelete corrupted files.
-filesPrint out files being checked.
-files -blocksPrint out the block report
-files -blocks -locationsPrint out locations for every block.
-files -blocks -racksPrint out network topology for data-node locations.
-files -blocks -replicaDetailsPrint out each replica details.
-files -blocks -upgradedomainsPrint out upgrade domains for every block.
-includeSnapshotsInclude snapshot data if the given path indicates a snapshottable directory or there are snapshottable directories under it.
-list-corruptfileblocksPrint out list of missing blocks and files they belong to.
-moveMove corrupted files to /lost+found.
-openforwritePrint out files opened for write.
-showprogressPrint out dots for progress in output. Default is OFF (no progress).
-storagepoliciesPrint out storage policy summary for the blocks.
-maintenancePrint out maintenance state node details.
-blockIdPrint out information about the block.

Runs the HDFS filesystem checking utility. See fsck for more info.

getconf

Usage:

   hdfs getconf -namenodes
   hdfs getconf -secondaryNameNodes
   hdfs getconf -backupNodes
   hdfs getconf -includeFile
   hdfs getconf -excludeFile
   hdfs getconf -nnRpcAddresses
   hdfs getconf -confKey [key]
COMMAND_OPTIONDescription
-namenodesgets list of namenodes in the cluster.
-secondaryNameNodesgets list of secondary namenodes in the cluster.
-backupNodesgets list of backup nodes in the cluster.
-includeFilegets the include file path that defines the datanodes that can join the cluster.
-excludeFilegets the exclude file path that defines the datanodes that need to decommissioned.
-nnRpcAddressesgets the namenode rpc addresses
-confKey [key]gets a specific key from the configuration

Gets configuration information from the configuration directory, post-processing.

groups

Usage: hdfs groups [username ...]

Returns the group information given one or more usernames.

httpfs

Usage: hdfs httpfs

Run HttpFS server, the HDFS HTTP Gateway.

lsSnapshottableDir

Usage: hdfs lsSnapshottableDir [-help]

COMMAND_OPTIONDescription
-helpprint help

Get the list of snapshottable directories. When this is run as a super user, it returns all snapshottable directories. Otherwise it returns those directories that are owned by the current user.

jmxget

Usage: hdfs jmxget [-localVM ConnectorURL | -port port | -server mbeanserver | -service service]

COMMAND_OPTIONDescription
-helpprint help
-localVM ConnectorURLconnect to the VM on the same machine
-port mbean server portspecify mbean server port, if missing it will try to connect to MBean Server in the same VM
-serverspecify mbean server (localhost by default)
-service NameNode|DataNodespecify jmx service. NameNode by default.

Dump JMX information from a service.

oev

Usage: hdfs oev [OPTIONS] -i INPUT_FILE -o OUTPUT_FILE

Required command line arguments:

COMMAND_OPTIONDescription
-i,--inputFile argedits file to process, xml (case insensitive) extension means XML format, any other filename means binary format
-o,--outputFile argName of output file. If the specified file exists, it will be overwritten, format of the file is determined by -p option

Optional command line arguments:

COMMAND_OPTIONDescription
-f,--fix-txidsRenumber the transaction IDs in the input, so that there are no gaps or invalid transaction IDs.
-h,--helpDisplay usage information and exit
-r,--recoverWhen reading binary edit logs, use recovery mode. This will give you the chance to skip corrupt parts of the edit log.
-p,--processor argSelect which type of processor to apply against image file, currently supported processors are: binary (native binary format that Hadoop uses), xml (default, XML format), stats (prints statistics about edits file)
-v,--verboseMore verbose output, prints the input and output filenames, for processors that write to a file, also output to screen. On large image files this will dramatically increase processing time (default is false).

Hadoop offline edits viewer. See Offline Edits Viewer Guide for more info.

oiv

Usage: hdfs oiv [OPTIONS] -i INPUT_FILE

Required command line arguments:

COMMAND_OPTIONDescription
-i|--inputFile input fileSpecify the input fsimage file (or XML file, if ReverseXML processor is used) to process.

Optional command line arguments:

COMMAND_OPTIONDescription
-o,--outputFile output fileSpecify the output filename, if the specified output processor generates one. If the specified file already exists, it is silently overwritten. (output to stdout by default) If the input file is an XML file, it also creates an <outputFile>.md5.
-p,--processor processorSpecify the image processor to apply against the image file. Currently valid options are Web (default), XML, Delimited, FileDistribution and ReverseXML.
-addr addressSpecify the address(host:port) to listen. (localhost:5978 by default). This option is used with Web processor.
-maxSize sizeSpecify the range [0, maxSize] of file sizes to be analyzed in bytes (128GB by default). This option is used with FileDistribution processor.
-step sizeSpecify the granularity of the distribution in bytes (2MB by default). This option is used with FileDistribution processor.
-formatFormat the output result in a human-readable fashion rather than a number of bytes. (false by default). This option is used with FileDistribution processor.
-delimiter argDelimiting string to use with Delimited processor.
-t,--temp temporary dirUse temporary dir to cache intermediate result to generate Delimited outputs. If not set, Delimited processor constructs the namespace in memory before outputting text.
-h,--helpDisplay the tool usage and help information and exit.

Hadoop Offline Image Viewer for image files in Hadoop 2.4 or up. See Offline Image Viewer Guide for more info.

oiv_legacy

Usage: hdfs oiv_legacy [OPTIONS] -i INPUT_FILE -o OUTPUT_FILE

COMMAND_OPTIONDescription
-i,--inputFile input fileSpecify the input fsimage file to process.
-o,--outputFile output fileSpecify the output filename, if the specified output processor generates one. If the specified file already exists, it is silently overwritten.

Optional command line arguments:

COMMAND_OPTIONDescription
-p|--processor processorSpecify the image processor to apply against the image file. Valid options are Ls (default), XML, Delimited, Indented, FileDistribution and NameDistribution.
-maxSize sizeSpecify the range [0, maxSize] of file sizes to be analyzed in bytes (128GB by default). This option is used with FileDistribution processor.
-step sizeSpecify the granularity of the distribution in bytes (2MB by default). This option is used with FileDistribution processor.
-formatFormat the output result in a human-readable fashion rather than a number of bytes. (false by default). This option is used with FileDistribution processor.
-skipBlocksDo not enumerate individual blocks within files. This may save processing time and outfile file space on namespaces with very large files. The Ls processor reads the blocks to correctly determine file sizes and ignores this option.
-printToScreenPipe output of processor to console as well as specified file. On extremely large namespaces, this may increase processing time by an order of magnitude.
-delimiter argWhen used in conjunction with the Delimited processor, replaces the default tab delimiter with the string specified by arg.
-h|--helpDisplay the tool usage and help information and exit.

Hadoop offline image viewer for older versions of Hadoop. See oiv_legacy Command for more info.

snapshotDiff

Usage: hdfs snapshotDiff <path> <fromSnapshot> <toSnapshot>

Determine the difference between HDFS snapshots. See the HDFS Snapshot Documentation for more information.

version

Usage: hdfs version

Prints the version.

Administration Commands

Commands useful for administrators of a hadoop cluster.

balancer

Usage:

    hdfs balancer
          [-policy <policy>]
          [-threshold <threshold>]
          [-exclude [-f <hosts-file> | <comma-separated list of hosts>]]
          [-include [-f <hosts-file> | <comma-separated list of hosts>]]
          [-source [-f <hosts-file> | <comma-separated list of hosts>]]
          [-blockpools <comma-separated list of blockpool ids>]
          [-idleiterations <idleiterations>]
          [-runDuringUpgrade]
COMMAND_OPTIONDescription
-policy <policy>datanode (default): Cluster is balanced if each datanode is balanced.
blockpool: Cluster is balanced if each block pool in each datanode is balanced.
-threshold <threshold>Percentage of disk capacity. This overwrites the default threshold.
-exclude -f <hosts-file> | <comma-separated list of hosts>Excludes the specified datanodes from being balanced by the balancer.
-include -f <hosts-file> | <comma-separated list of hosts>Includes only the specified datanodes to be balanced by the balancer.
-source -f <hosts-file> | <comma-separated list of hosts>Pick only the specified datanodes as source nodes.
-blockpools <comma-separated list of blockpool ids>The balancer will only run on blockpools included in this list.
-idleiterations <iterations>Maximum number of idle iterations before exit. This overwrites the default idleiterations(5).
-runDuringUpgradeWhether to run the balancer during an ongoing HDFS upgrade. This is usually not desired since it will not affect used space on over-utilized machines.
-h|--helpDisplay the tool usage and help information and exit.

Runs a cluster balancing utility. An administrator can simply press Ctrl-C to stop the rebalancing process. See Balancer for more details.

Note that the blockpool policy is more strict than the datanode policy.

Besides the above command options, a pinning feature is introduced starting from 2.7.0 to prevent certain replicas from getting moved by balancer/mover. This pinning feature is disabled by default, and can be enabled by configuration property “dfs.datanode.block-pinning.enabled”. When enabled, this feature only affects blocks that are written to favored nodes specified in the create() call. This feature is useful when we want to maintain the data locality, for applications such as HBase regionserver.

cacheadmin

Usage:

hdfs cacheadmin [-addDirective -path <path> -pool <pool-name> [-force] [-replication <replication>] [-ttl <time-to-live>]]
hdfs cacheadmin [-modifyDirective -id <id> [-path <path>] [-force] [-replication <replication>] [-pool <pool-name>] [-ttl <time-to-live>]]
hdfs cacheadmin [-listDirectives [-stats] [-path <path>] [-pool <pool>] [-id <id>]]
hdfs cacheadmin [-removeDirective <id>]
hdfs cacheadmin [-removeDirectives -path <path>]
hdfs cacheadmin [-addPool <name> [-owner <owner>] [-group <group>] [-mode <mode>] [-limit <limit>] [-maxTtl <maxTtl>]]
hdfs cacheadmin [-modifyPool <name> [-owner <owner>] [-group <group>] [-mode <mode>] [-limit <limit>] [-maxTtl <maxTtl>]]
hdfs cacheadmin [-removePool <name>]
hdfs cacheadmin [-listPools [-stats] [<name>]]
hdfs cacheadmin [-help <command-name>]

See the HDFS Cache Administration Documentation for more information.

crypto

Usage:

  hdfs crypto -createZone -keyName <keyName> -path <path>
  hdfs crypto -listZones
  hdfs crypto -provisionTrash -path <path>
  hdfs crypto -help <command-name>

See the HDFS Transparent Encryption Documentation for more information.

datanode

Usage: hdfs datanode [-regular | -rollback | -rollingupgrade rollback]

COMMAND_OPTIONDescription
-regularNormal datanode startup (default).
-rollbackRollback the datanode to the previous version. This should be used after stopping the datanode and distributing the old hadoop version.
-rollingupgrade rollbackRollback a rolling upgrade operation.

Runs a HDFS datanode.

dfsadmin

Usage:

    hdfs dfsadmin [-report [-live] [-dead] [-decommissioning] [-enteringmaintenance] [-inmaintenance]]
    hdfs dfsadmin [-safemode enter | leave | get | wait | forceExit]
    hdfs dfsadmin [-saveNamespace [-beforeShutdown]]
    hdfs dfsadmin [-rollEdits]
    hdfs dfsadmin [-restoreFailedStorage true |false |check]
    hdfs dfsadmin [-refreshNodes]
    hdfs dfsadmin [-setQuota <quota> <dirname>...<dirname>]
    hdfs dfsadmin [-clrQuota <dirname>...<dirname>]
    hdfs dfsadmin [-setSpaceQuota <quota> [-storageType <storagetype>] <dirname>...<dirname>]
    hdfs dfsadmin [-clrSpaceQuota [-storageType <storagetype>] <dirname>...<dirname>]
    hdfs dfsadmin [-finalizeUpgrade]
    hdfs dfsadmin [-rollingUpgrade [<query> |<prepare> |<finalize>]]
    hdfs dfsadmin [-refreshServiceAcl]
    hdfs dfsadmin [-refreshUserToGroupsMappings]
    hdfs dfsadmin [-refreshSuperUserGroupsConfiguration]
    hdfs dfsadmin [-refreshCallQueue]
    hdfs dfsadmin [-refresh <host:ipc_port> <key> [arg1..argn]]
    hdfs dfsadmin [-reconfig <namenode|datanode> <host:ipc_port> <start |status |properties>]
    hdfs dfsadmin [-printTopology]
    hdfs dfsadmin [-refreshNamenodes datanodehost:port]
    hdfs dfsadmin [-getVolumeReport datanodehost:port]
    hdfs dfsadmin [-deleteBlockPool datanode-host:port blockpoolId [force]]
    hdfs dfsadmin [-setBalancerBandwidth <bandwidth in bytes per second>]
    hdfs dfsadmin [-getBalancerBandwidth <datanode_host:ipc_port>]
    hdfs dfsadmin [-fetchImage <local directory>]
    hdfs dfsadmin [-allowSnapshot <snapshotDir>]
    hdfs dfsadmin [-disallowSnapshot <snapshotDir>]
    hdfs dfsadmin [-shutdownDatanode <datanode_host:ipc_port> [upgrade]]
    hdfs dfsadmin [-evictWriters <datanode_host:ipc_port>]
    hdfs dfsadmin [-getDatanodeInfo <datanode_host:ipc_port>]
    hdfs dfsadmin [-metasave filename]
    hdfs dfsadmin [-triggerBlockReport [-incremental] <datanode_host:ipc_port>]
    hdfs dfsadmin [-listOpenFiles [-blockingDecommission] [-path <path>]]
    hdfs dfsadmin [-help [cmd]]
COMMAND_OPTIONDescription
-report [-live] [-dead] [-decommissioning] [-enteringmaintenance] [-inmaintenance]Reports basic filesystem information and statistics, The dfs usage can be different from “du” usage, because it measures raw space used by replication, checksums, snapshots and etc. on all the DNs. Optional flags may be used to filter the list of displayed DataNodes.
-safemode enter|leave|get|wait|forceExitSafe mode maintenance command. Safe mode is a Namenode state in which it
1. does not accept changes to the name space (read-only)
2. does not replicate or delete blocks.
Safe mode is entered automatically at Namenode startup, and leaves safe mode automatically when the configured minimum percentage of blocks satisfies the minimum replication condition. If Namenode detects any anomaly then it will linger in safe mode till that issue is resolved. If that anomaly is the consequence of a deliberate action, then administrator can use -safemode forceExit to exit safe mode. The cases where forceExit may be required are
1. Namenode metadata is not consistent. If Namenode detects that metadata has been modified out of band and can cause data loss, then Namenode will enter forceExit state. At that point user can either restart Namenode with correct metadata files or forceExit (if data loss is acceptable).
2. Rollback causes metadata to be replaced and rarely it can trigger safe mode forceExit state in Namenode. In that case you may proceed by issuing -safemode forceExit.
Safe mode can also be entered manually, but then it can only be turned off manually as well.
-saveNamespace [-beforeShutdown]Save current namespace into storage directories and reset edits log. Requires safe mode. If the “beforeShutdown” option is given, the NameNode does a checkpoint if and only if no checkpoint has been done during a time window (a configurable number of checkpoint periods). This is usually used before shutting down the NameNode to prevent potential fsimage/editlog corruption.
-rollEditsRolls the edit log on the active NameNode.
-restoreFailedStorage true|false|checkThis option will turn on/off automatic attempt to restore failed storage replicas. If a failed storage becomes available again the system will attempt to restore edits and/or fsimage during checkpoint. ‘check’ option will return current setting.
-refreshNodesRe-read the hosts and exclude files to update the set of Datanodes that are allowed to connect to the Namenode and those that should be decommissioned or recommissioned.
-setQuota <quota> <dirname>...<dirname>See HDFS Quotas Guide for the detail.
-clrQuota <dirname>...<dirname>See HDFS Quotas Guide for the detail.
-setSpaceQuota <quota> [-storageType <storagetype>] <dirname>...<dirname>See HDFS Quotas Guide for the detail.
-clrSpaceQuota [-storageType <storagetype>] <dirname>...<dirname>See HDFS Quotas Guide for the detail.
-finalizeUpgradeFinalize upgrade of HDFS. Datanodes delete their previous version working directories, followed by Namenode doing the same. This completes the upgrade process.
-rollingUpgrade [<query>|<prepare>|<finalize>]See Rolling Upgrade document for the detail.
-refreshServiceAclReload the service-level authorization policy file.
-refreshUserToGroupsMappingsRefresh user-to-groups mappings.
-refreshSuperUserGroupsConfigurationRefresh superuser proxy groups mappings
-refreshCallQueueReload the call queue from config.
-refresh <host:ipc_port> <key> [arg1..argn]Triggers a runtime-refresh of the resource specified by <key> on <host:ipc_port>. All other args after are sent to the host.
-reconfig <datanode |namenode> <host:ipc_port> <start|status|properties>Starts reconfiguration or gets the status of an ongoing reconfiguration, or gets a list of reconfigurable properties. The second parameter specifies the node type.
-printTopologyPrint a tree of the racks and their nodes as reported by the Namenode
-refreshNamenodes datanodehost:portFor the given datanode, reloads the configuration files, stops serving the removed block-pools and starts serving new block-pools.
-getVolumeReport datanodehost:portFor the given datanode, get the volume report.
-deleteBlockPool datanode-host:port blockpoolId [force]If force is passed, block pool directory for the given blockpool id on the given datanode is deleted along with its contents, otherwise the directory is deleted only if it is empty. The command will fail if datanode is still serving the block pool. Refer to refreshNamenodes to shutdown a block pool service on a datanode.
-setBalancerBandwidth <bandwidth in bytes per second>Changes the network bandwidth used by each datanode during HDFS block balancing. <bandwidth> is the maximum number of bytes per second that will be used by each datanode. This value overrides the dfs.datanode.balance.bandwidthPerSec parameter. NOTE: The new value is not persistent on the DataNode.
-getBalancerBandwidth <datanode_host:ipc_port>Get the network bandwidth(in bytes per second) for the given datanode. This is the maximum network bandwidth used by the datanode during HDFS block balancing.
-fetchImage <local directory>Downloads the most recent fsimage from the NameNode and saves it in the specified local directory.
-allowSnapshot <snapshotDir>Allowing snapshots of a directory to be created. If the operation completes successfully, the directory becomes snapshottable. See the HDFS Snapshot Documentation for more information.
-disallowSnapshot <snapshotDir>Disallowing snapshots of a directory to be created. All snapshots of the directory must be deleted before disallowing snapshots. See the HDFS Snapshot Documentation for more information.
-shutdownDatanode <datanode_host:ipc_port> [upgrade]Submit a shutdown request for the given datanode. See Rolling Upgrade document for the detail.
-evictWriters <datanode_host:ipc_port>Make the datanode evict all clients that are writing a block. This is useful if decommissioning is hung due to slow writers.
-getDatanodeInfo <datanode_host:ipc_port>Get the information about the given datanode. See Rolling Upgrade document for the detail.
-metasave filenameSave Namenode's primary data structures to filename in the directory specified by hadoop.log.dir property. filename is overwritten if it exists. filename will contain one line for each of the following
1. Datanodes heart beating with Namenode
2. Blocks waiting to be replicated
3. Blocks currently being replicated
4. Blocks waiting to be deleted
-triggerBlockReport [-incremental] <datanode_host:ipc_port>Trigger a block report for the given datanode. If ‘incremental’ is specified, it will be otherwise, it will be a full block report.
-listOpenFiles [-blockingDecommission] [-path <path>]List all open files currently managed by the NameNode along with client name and client machine accessing them. Open files list will be filtered by given type and path.
-help [cmd]Displays help for the given command or all commands if none is specified.

Runs a HDFS dfsadmin client.

dfsrouter

Usage: hdfs dfsrouter

Runs the DFS router. See Router for more info.

dfsrouteradmin

Usage:

  hdfs dfsrouteradmin
      [-add <source> <nameservice> <destination> [-readonly]]
      [-rm <source>]
      [-ls <path>]
COMMAND_OPTIONDescription
-add source nameservice destinationAdd a mount table entry or update if it exists.
-rm sourceRemove mount point of specified path.
-ls pathList mount points under specified path.

The commands for managing Router-based federation. See Mount table management for more info.

diskbalancer

Usage:

   hdfs diskbalancer
     [-plan <datanode> -fs <namenodeURI>]
     [-execute <planfile>]
     [-query <datanode>]
     [-cancel <planfile>]
     [-cancel <planID> -node <datanode>]
     [-report -node <file://> | [<DataNodeID|IP|Hostname>,...]]
     [-report -node -top <topnum>]
COMMAND_OPTIONDescription
-planCreates a disbalancer plan
-executeExecutes a given plan on a datanode
-queryGets the current diskbalancer status from a datanode
-cancelCancels a running plan
-reportReports the volume information from datanode(s)

Runs the diskbalancer CLI. See HDFS Diskbalancer for more information on this command.

ec

Usage:

   hdfs ec [generic options]
     [-setPolicy -policy <policyName> -path <path>]
     [-getPolicy -path <path>]
     [-unsetPolicy -path <path>]
     [-listPolicies]
     [-addPolicies -policyFile <file>]
     [-listCodecs]
     [-enablePolicy -policy <policyName>]
     [-disablePolicy -policy <policyName>]
     [-help [cmd ...]]
COMMAND_OPTIONDescription
-setPolicySet a specified ErasureCoding policy to a directory
-getPolicyGet ErasureCoding policy information about a specified path
-unsetPolicyUnset an ErasureCoding policy set by a previous call to “setPolicy” on a directory
-listPoliciesLists all supported ErasureCoding policies
-addPoliciesAdd a list of erasure coding policies
-listCodecsGet the list of supported erasure coding codecs and coders in system
-enablePolicyEnable an ErasureCoding policy in system
-disablePolicyDisable an ErasureCoding policy in system

Runs the ErasureCoding CLI. See HDFS ErasureCoding for more information on this command.

haadmin

Usage:

    hdfs haadmin -transitionToActive <serviceId> [--forceactive]
    hdfs haadmin -transitionToStandby <serviceId>
    hdfs haadmin -failover [--forcefence] [--forceactive] <serviceId> <serviceId>
    hdfs haadmin -getServiceState <serviceId>
    hdfs haadmin -getAllServiceState
    hdfs haadmin -checkHealth <serviceId>
    hdfs haadmin -help <command>
COMMAND_OPTIONDescription
-checkHealthcheck the health of the given NameNode
-failoverinitiate a failover between two NameNodes
-getServiceStatedetermine whether the given NameNode is Active or Standby
-getAllServiceStatereturns the state of all the NameNodes
-transitionToActivetransition the state of the given NameNode to Active (Warning: No fencing is done)
-transitionToStandbytransition the state of the given NameNode to Standby (Warning: No fencing is done)
-help [cmd]Displays help for the given command or all commands if none is specified.

See HDFS HA with NFS or HDFS HA with QJM for more information on this command.

journalnode

Usage: hdfs journalnode

This comamnd starts a journalnode for use with HDFS HA with QJM.

mover

Usage: hdfs mover [-p <files/dirs> | -f <local file name>]

COMMAND_OPTIONDescription
-f <local file>Specify a local file containing a list of HDFS files/dirs to migrate.
-p <files/dirs>Specify a space separated list of HDFS files/dirs to migrate.

Runs the data migration utility. See Mover for more details.

Note that, when both -p and -f options are omitted, the default path is the root directory.

In addition, a pinning feature is introduced starting from 2.7.0 to prevent certain replicas from getting moved by balancer/mover. This pinning feature is disabled by default, and can be enabled by configuration property “dfs.datanode.block-pinning.enabled”. When enabled, this feature only affects blocks that are written to favored nodes specified in the create() call. This feature is useful when we want to maintain the data locality, for applications such as HBase regionserver.

namenode

Usage:

  hdfs namenode [-backup] |
          [-checkpoint] |
          [-format [-clusterid cid ] [-force] [-nonInteractive] ] |
          [-upgrade [-clusterid cid] [-renameReserved<k-v pairs>] ] |
          [-upgradeOnly [-clusterid cid] [-renameReserved<k-v pairs>] ] |
          [-rollback] |
          [-rollingUpgrade <rollback |started> ] |
          [-importCheckpoint] |
          [-initializeSharedEdits] |
          [-bootstrapStandby [-force] [-nonInteractive] [-skipSharedEditsCheck] ] |
          [-recover [-force] ] |
          [-metadataVersion ]
COMMAND_OPTIONDescription
-backupStart backup node.
-checkpointStart checkpoint node.
-format [-clusterid cid]Formats the specified NameNode. It starts the NameNode, formats it and then shut it down. Will throw NameNodeFormatException if name dir already exist and if reformat is disabled for cluster.
-upgrade [-clusterid cid] [-renameReserved <k-v pairs>]Namenode should be started with upgrade option after the distribution of new Hadoop version.
-upgradeOnly [-clusterid cid] [-renameReserved <k-v pairs>]Upgrade the specified NameNode and then shutdown it.
-rollbackRollback the NameNode to the previous version. This should be used after stopping the cluster and distributing the old Hadoop version.
-rollingUpgrade <rollback|started>See Rolling Upgrade document for the detail.
-importCheckpointLoads image from a checkpoint directory and save it into the current one. Checkpoint dir is read from property dfs.namenode.checkpoint.dir
-initializeSharedEditsFormat a new shared edits dir and copy in enough edit log segments so that the standby NameNode can start up.
-bootstrapStandby [-force] [-nonInteractive] [-skipSharedEditsCheck]Allows the standby NameNode's storage directories to be bootstrapped by copying the latest namespace snapshot from the active NameNode. This is used when first configuring an HA cluster. The option -force or -nonInteractive has the same meaning as that described in namenode -format command. -skipSharedEditsCheck option skips edits check which ensures that we have enough edits already in the shared directory to start up from the last checkpoint on the active.
-recover [-force]Recover lost metadata on a corrupt filesystem. See HDFS User Guide for the detail.
-metadataVersionVerify that configured directories exist, then print the metadata versions of the software and the image.

Runs the namenode. More info about the upgrade and rollback is at Upgrade Rollback.

nfs3

Usage: hdfs nfs3

This comamnd starts the NFS3 gateway for use with the HDFS NFS3 Service.

portmap

Usage: hdfs portmap

This comamnd starts the RPC portmap for use with the HDFS NFS3 Service.

secondarynamenode

Usage: hdfs secondarynamenode [-checkpoint [force]] | [-format] | [-geteditsize]

COMMAND_OPTIONDescription
-checkpoint [force]Checkpoints the SecondaryNameNode if EditLog size >= fs.checkpoint.size. If force is used, checkpoint irrespective of EditLog size.
-formatFormat the local storage during startup.
-geteditsizePrints the number of uncheckpointed transactions on the NameNode.

Runs the HDFS secondary namenode. See Secondary Namenode for more info.

storagepolicies

Usage:

  hdfs storagepolicies
      [-listPolicies]
      [-setStoragePolicy -path <path> -policy <policy>]
      [-getStoragePolicy -path <path>]
      [-unsetStoragePolicy -path <path>]
      [-help <command-name>]

Lists out all/Gets/sets/unsets storage policies. See the HDFS Storage Policy Documentation for more information.

zkfc

Usage: hdfs zkfc [-formatZK [-force] [-nonInteractive]]

COMMAND_OPTIONDescription
-formatZKFormat the Zookeeper instance. -force: formats the znode if the znode exists. -nonInteractive: formats the znode aborts if the znode exists, unless -force option is specified.
-hDisplay help

This comamnd starts a Zookeeper Failover Controller process for use with HDFS HA with QJM.

Debug Commands

Useful commands to help administrators debug HDFS issues. These commands are for advanced users only.

verifyMeta

Usage: hdfs debug verifyMeta -meta <metadata-file> [-block <block-file>]

COMMAND_OPTIONDescription
-block block-fileOptional parameter to specify the absolute path for the block file on the local file system of the data node.
-meta metadata-fileAbsolute path for the metadata file on the local file system of the data node.

Verify HDFS metadata and block files. If a block file is specified, we will verify that the checksums in the metadata file match the block file.

computeMeta

Usage: hdfs debug computeMeta -block <block-file> -out <output-metadata-file>

COMMAND_OPTIONDescription
-block block-fileAbsolute path for the block file on the local file system of the data node.
-out output-metadata-fileAbsolute path for the output metadata file to store the checksum computation result from the block file.

Compute HDFS metadata from block files. If a block file is specified, we will compute the checksums from the block file, and save it to the specified output metadata file.

NOTE: Use at your own risk! If the block file is corrupt and you overwrite it‘s meta file, it will show up as ‘good’ in HDFS, but you can’t read the data. Only use as a last measure, and when you are 100% certain the block file is good.

recoverLease

Usage: hdfs debug recoverLease -path <path> [-retries <num-retries>]

COMMAND_OPTIONDescription
[-path path]HDFS path for which to recover the lease.
[-retries num-retries]Number of times the client will retry calling recoverLease. The default number of retries is 1.

Recover the lease on the specified path. The path must reside on an HDFS filesystem. The default number of retries is 1.