概觀(Overview)html
全部HDFS命令都由$HADOOP_HOME/bin/hdfs腳本調用。不帶任何參數運行hdfs腳本將打印全部命令的描述。node
Usage: hdfs [--config confdir] [COMMAND] [GENERIC_OPTIONS] [COMMAND_OPTIONS]web
命令選項apache |
描述bootstrap |
--config confdir安全 |
Overwrites the default Configuration directory. Default is $HADOOP_HOME/conf.網絡 覆蓋默認的配置目錄。默認值是$ HADOOP_HOME / conf。數據結構 |
GENERIC_OPTIONSapp |
The common set of options supported by multiple commands. Full list is here.less 多個命令支持的一組經常使用選項。 |
COMMAND_OPTIONS |
Various commands with their options are described in the following sections. The commands have been grouped into and . 如下各節介紹了各類命令及其選項。這些命令已被分組。 |
用戶命令(User Commands)
dfs
Usage: hdfs dfs [GENERIC_OPTIONS] [COMMAND_OPTIONS]
在Hadoop支持的文件系統上運行文件系統命令。各類COMMAND_OPTIONS能夠在File System Shell Guide中找到。
fetchdt
從NameNode獲取受權令牌。有關更多信息,請參閱fetchdt。
Usage: hdfs fetchdt [GENERIC_OPTIONS] [--webservice <namenode_http_addr>] <path>
命令選項 |
描述 |
fileName |
File name to store the token into. 用於存儲令牌的文件名。 |
--webservice https_address |
use http protocol instead of RPC 使用http協議而不是RPC |
fsck
運行HDFS文件系統檢查實用程序。有關更多信息,請參閱fsck。
Usage: hdfs fsck [GENERIC_OPTIONS] <path> [-list-corruptfileblocks | [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]] [-includeSnapshots]
命令選項 |
描述 |
path |
Start checking from this path. 今後路徑開始檢查。 |
-move |
Move corrupted files to /lost+found 將損壞的文件移至/ lost + found |
-delete |
Delete corrupted files. 刪除損壞的文件。 |
-files |
Print out files being checked. 打印出正在檢查的文件。 |
-openforwrite |
Print out files opened for write. 打印出能夠寫入的文件。 |
-includeSnapshots |
Include snapshot data if the given path indicates a snapshottable directory or there are snapshottable directories under it. 若是給定路徑指示快照可用目錄或其下有快照可用目錄,則包含快照數據。 |
-list-corruptfileblocks |
Print out list of missing blocks and files they belong to. 打印出它們所屬的缺失塊和文件列表。 |
-blocks |
Print out block report. 打印塊報告。 |
-locations |
Print out locations for every block. 打印每一個塊的位置。 |
-racks |
Print out network topology for data-node locations. 打印出數據節點位置的網絡拓撲。 |
version
打印版本
Usage: hdfs version
管理命令(Administration Commands)
balancer
運行集羣平衡實用程序。管理員能夠簡單地按下Ctrl-C來中止從新平衡過程。有關更多詳情,請參閱 Balancer。
Usage: hdfs balancer [-threshold <threshold>] [-policy <policy>]
命令選項 |
描述 |
-threshold threshold |
Percentage of disk capacity. This overwrites the default threshold. 磁盤容量的百分比。這會覆蓋默認的閾值。 |
-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. datanode(默認):若是每一個datanode是平衡的,則集羣是平衡的。 blockpool:若是每一個數據節點中的每一個塊池均衡,則集羣將保持平衡。 |
datanode
運行HDFS數據節點。
Usage: hdfs datanode [-regular | -rollback | -rollingupgrace rollback]
命令選項 |
描述 |
-regular |
Normal datanode startup (default). 正常的datanode啓動(默認)。 |
-rollback |
Rollback the datanode to the previous version. This should be used after stopping the datanode and distributing the old hadoop version. 將datanode回滾到之前的版本。這應該在中止Datanode並分發舊的hadoop版本後使用。 |
-rollingupgrade rollback |
Rollback a rolling upgrade operation. 回滾滾動升級操做。 |
dfsadmin
運行HDFS dfsadmin客戶端。
Usage: hdfs dfsadmin [GENERIC_OPTIONS]
[-report [-live] [-dead] [-decommissioning]]
[-safemode enter | leave | get | wait]
[-saveNamespace]
[-rollEdits]
[-restoreFailedStorage true|false|check]
[-refreshNodes]
[-setQuota <quota> <dirname>...<dirname>]
[-clrQuota <dirname>...<dirname>]
[-setSpaceQuota <quota> <dirname>...<dirname>]
[-clrSpaceQuota <dirname>...<dirname>]
[-setStoragePolicy <path> <policyName>]
[-getStoragePolicy <path>]
[-finalizeUpgrade]
[-rollingUpgrade [<query>|<prepare>|<finalize>]]
[-metasave filename]
[-refreshServiceAcl]
[-refreshUserToGroupsMappings]
[-refreshSuperUserGroupsConfiguration]
[-refreshCallQueue]
[-refresh <host:ipc_port> <key> [arg1..argn]]
[-printTopology]
[-refreshNamenodes datanodehost:port]
[-deleteBlockPool datanode-host:port blockpoolId [force]]
[-setBalancerBandwidth <bandwidth in bytes per second>]
[-allowSnapshot <snapshotDir>]
[-disallowSnapshot <snapshotDir>]
[-fetchImage <local directory>]
[-shutdownDatanode <datanode_host:ipc_port> [upgrade]]
[-getDatanodeInfo <datanode_host:ipc_port>]
[-triggerBlockReport [-incremental] <datanode_host:ipc_port>]
[-help [cmd]]
命令選項 |
描述 |
-report [-live] [-dead] [-decommissioning] |
Reports basic filesystem information and statistics. Optional flags may be used to filter the list of displayed DataNodes. 報告基本的文件系統信息和統計。可選標誌可用於過濾顯示的數據節點列表。 |
-safemode enter|leave|get|wait |
Safe 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. Safe mode can also be entered manually, but then it can only be turned off manually as well. 安全模式維護命令。安全模式是Namenode狀態,其中 1.不接受對名稱空間的更改(只讀) 2.不復制或刪除塊。 安全模式是在Namenode啓動時自動輸入的,當配置的塊的最小百分比知足最小複製條件時,將自動離開安全模式。安全模式也能夠手動輸入,但只能手動關閉。 |
-saveNamespace |
Save current namespace into storage directories and reset edits log. Requires safe mode. 將當前名稱空間保存到存儲目錄並重置編輯日誌。須要安全模式。 |
-rollEdits |
Rolls the edit log on the active NameNode. 在活動的NameNode上滾動編輯日誌。 |
-restoreFailedStorage true|false|check |
This 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. 該選項將打開/關閉自動嘗試恢復失敗的存儲副本。若是失敗的存儲器再次可用,則系統將在檢查點期間嘗試恢復編輯和/或fsimage。'check'選項將返回當前設置。 |
-refreshNodes |
Re-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. 從新讀取主機並排除文件以更新容許鏈接到Namenode的那組Datanode以及那些應該停用或從新試用的Datanode。 |
-setQuota <quota> <dirname>...<dirname> |
See HDFS Quotas Guide for the detail. 有關詳細信息,請參閱HDFS配額指南。 |
-clrQuota <dirname>...<dirname> |
See HDFS Quotas Guide for the detail. 有關詳細信息,請參閱HDFS配額指南。 |
-setSpaceQuota <quota> <dirname>...<dirname> |
See HDFS Quotas Guide for the detail. 有關詳細信息,請參閱HDFS配額指南。 |
-clrSpaceQuota <dirname>...<dirname> |
See HDFS Quotas Guide for the detail. 有關詳細信息,請參閱HDFS配額指南。 |
-setStoragePolicy <path> <policyName> |
Set a storage policy to a file or a directory. 將存儲策略設置爲文件或目錄。 |
-getStoragePolicy <path> |
Get the storage policy of a file or a directory. 獲取文件或目錄的存儲策略。 |
-finalizeUpgrade |
Finalize upgrade of HDFS. Datanodes delete their previous version working directories, followed by Namenode doing the same. This completes the upgrade process. 完成HDFS的升級。Datanodes刪除他們之前的版本工做目錄,而後Namenode作相同的工做。這完成了升級過程。 |
-rollingUpgrade [<query>|<prepare>|<finalize>] |
See Rolling Upgrade document for the detail. 有關詳細信息,請參閱滾動升級文檔。 |
-metasave filename |
Save 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 將Namenode的主要數據結構保存到由hadoop.log.dir屬性指定的目錄中的文件名。若是它存在,則文件名被覆蓋。文件名將包含如下每行的一行 1. Datanodes的心跳與Namenode 2.等待被複制的塊 3.當前正在複製的塊 4.等待被刪除的塊 |
-refreshServiceAcl |
Reload the service-level authorization policy file. 從新加載服務級別受權策略文件。 |
-refreshUserToGroupsMappings |
Refresh user-to-groups mappings. 刷新用戶到組映射。 |
-refreshSuperUserGroupsConfiguration |
Refresh superuser proxy groups mappings 刷新超級用戶代理組映射 |
-refreshCallQueue |
Reload 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. 觸發<host:ipc_port>上由<key>指定的資源的運行時刷新。全部其餘參數都發送給主機。 |
-printTopology |
Print a tree of the racks and their nodes as reported by the Namenode 打印由Namenode報告的機架及其節點的樹 |
-refreshNamenodes datanodehost:port |
For the given datanode, reloads the configuration files, stops serving the removed block-pools and starts serving new block-pools. 對於給定的datanode,從新加載配置文件,中止提供已移除的塊池並開始提供新的塊池。 |
-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. 若是強制傳遞,給定數據節點上的給定塊池ID的塊池目錄與其內容一塊兒被刪除,不然該目錄僅在其爲空時才被刪除。若是datanode仍在服務塊池,該命令將失敗。請參閱refreshNamenodes關閉數據節點上的塊池服務。 |
-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.balance.bandwidthPerSec parameter. NOTE: The new value is not persistent on the DataNode. 在HDFS塊平衡期間更改每一個數據節點使用的網絡帶寬。<bandwidth>是每一個datanode將使用的每秒最大字節數。該值將覆蓋dfs.balance.bandwidthPerSec參數。 注意:新值在DataNode上不是永久的。 |
-allowSnapshot <snapshotDir> |
Allowing snapshots of a directory to be created. If the operation completes successfully, the directory becomes snapshottable. 容許建立目錄的快照。若是操做成功完成,則該目錄變爲快照可見。 |
-disallowSnapshot <snapshotDir> |
Disallowing snapshots of a directory to be created. All snapshots of the directory must be deleted before disallowing snapshots. 禁止要建立的目錄的快照。在禁用快照以前,必須刪除目錄的全部快照。 |
-fetchImage <local directory> |
Downloads the most recent fsimage from the NameNode and saves it in the specified local directory. 從NameNode下載最新的fsimage並將其保存在指定的本地目錄中。 |
-shutdownDatanode <datanode_host:ipc_port> [upgrade] |
Submit a shutdown request for the given datanode. See Rolling Upgrade document for the detail. 爲給定的datanode提交關閉請求。有關詳細信息,請參閱滾動升級文檔。 |
-getDatanodeInfo <datanode_host:ipc_port> |
Get the information about the given datanode. See Rolling Upgrade document for the detail. 獲取有關給定datanode的信息。有關詳細信息,請參閱滾動升級文檔。 |
-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. 觸發給定數據節點的塊報告。若是指定了'增量',那麼將會是一個完整的塊報告。 |
-help [cmd] |
Displays help for the given command or all commands if none is specified. 若是沒有指定,則顯示給定命令的幫助或全部命令。 |
mover
運行數據遷移實用程序。有關更多詳情,請參閱移動器。
Usage: hdfs mover [-p <files/dirs> | -f <local file name>]
命令選項 |
描述 |
-p <files/dirs> |
Specify a space separated list of HDFS files/dirs to migrate. 指定要遷移的HDFS文件/目錄的空格分隔列表。 |
-f <local file> |
Specify a local file containing a list of HDFS files/dirs to migrate. 指定一個包含要遷移的HDFS文件/目錄列表的本地文件。 |
請注意,若是省略-p和-f選項,則默認路徑是根目錄。
namenode
運行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 <downgrade|rollback> ] |
[-finalize] |
[-importCheckpoint] |
[-initializeSharedEdits] |
[-bootstrapStandby] |
[-recover [-force] ] |
[-metadataVersion ]
命令選項 |
描述 |
-backup |
Start backup node. 啓動備份節點。 |
-checkpoint |
Start checkpoint node. 啓動檢查點節點。 |
-format [-clusterid cid] [-force] [-nonInteractive] |
Formats the specified NameNode. It starts the NameNode, formats it and then shut it down. -force option formats if the name directory exists. -nonInteractive option aborts if the name directory exists, unless -force option is specified. 格式化指定的NameNode。它啓動NameNode,對其進行格式化,而後關閉它。-force選項格式,若是名稱目錄存在。若是名稱目錄存在,-nonInteractive選項將停止,除非指定了-force選項。 |
-upgrade [-clusterid cid] [-renameReserved<k-v pairs>] |
Namenode should be started with upgrade option after the distribution of new Hadoop version. 在發佈新的Hadoop版本後,Namenode應該以升級選項啓動。 |
-upgradeOnly [-clusterid cid] [-renameReserved<k-v pairs>] |
Upgrade the specified NameNode and then shutdown it. 升級指定的NameNode,而後關閉它。 |
-rollback |
Rollback the NameNode to the previous version. This should be used after stopping the cluster and distributing the old Hadoop version. 將NameNode回滾到之前的版本。這應該在中止集羣並分發舊的Hadoop版本後使用。 |
-rollingUpgrade <downgrade|rollback|started> |
See Rolling Upgrade document for the detail. 有關詳細信息,請參閱滾動升級文檔。 |
-finalize |
Finalize will remove the previous state of the files system. Recent upgrade will become permanent. Rollback option will not be available anymore. After finalization it shuts the NameNode down. Finalize將刪除文件系統的先前狀態。最近的升級將會變得永久。回滾選項將再也不可用。完成後它會關閉NameNode。 |
-importCheckpoint |
Loads image from a checkpoint directory and save it into the current one. Checkpoint dir is read from property fs.checkpoint.dir 從檢查點目錄加載圖像並將其保存到當前目錄中。檢查點目錄是從屬性fs.checkpoint.dir中讀取的 |
-initializeSharedEdits |
Format a new shared edits dir and copy in enough edit log segments so that the standby NameNode can start up. 格式化新的共享編輯目錄並複製足夠的編輯日誌段,以便備用NameNode能夠啓動。 |
-bootstrapStandby |
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. 容許經過複製活動NameNode中的最新命名空間快照來引導備用NameNode的存儲目錄。這在首次配置HA羣集時使用。 |
-recover [-force] |
Recover lost metadata on a corrupt filesystem. See HDFS User Guide for the detail. 在損壞的文件系統上恢復丟失的元數據。詳情請參閱HDFS用戶指南。 |
-metadataVersion |
Verify that configured directories exist, then print the metadata versions of the software and the image. 驗證配置的目錄是否存在,而後打印軟件和圖像的元數據版本。 |
secondarynamenode
運行HDFS輔助名稱節點。有關更多信息,請參閱第二名稱節點。
Usage: hdfs secondarynamenode [-checkpoint [force]] | [-format] | [-geteditsize]
命令選項 |
描述 |
-checkpoint [force] |
Checkpoints the SecondaryNameNode if EditLog size >= fs.checkpoint.size. If force is used, checkpoint irrespective of EditLog size. 若是EditLog大小> = fs.checkpoint.size,則檢查SecondaryNameNode。若是使用強制,則不考慮EditLog大小。 |
-format |
Format the local storage during startup. 在啓動期間格式化本地存儲。 |
-geteditsize |
Prints the number of uncheckpointed transactions on the NameNode. 在NameNode上打印未勾選事務的數量。 |