Balancer commands
You can use various command line options with the hdfs balancer command to work with the HDFS Balancer.
Balancing policy, threshold, and blockpools
- [-policy <policy>]
-
Specifies which policy to use to determine if a cluster is balanced.
The two supported policies are
blockpool
anddatanode
. Setting the policy toblockpool
means that the cluster is balanced if each pool in each node is balanced whiledatanode
means that a cluster is balanced if each DataNode is balanced.The default policy is
datanode
. - [-threshold <threshold>]
-
Specifies a number in [1.0, 100.0] representing the acceptable threshold of the percentage of storage capacity so that storage utilization outside the average +/- the threshold is considered as over/under utilized.
The default threshold is 10.0.
- [-blockpools <comma-separated list of blockpool ids>]
-
Specifies a list of block pools on which the HDFS Balancer runs. If the list is empty, the HDFS Balancer runs on all existing block pools.
The default value is an empty list.
Include and exclude lists
- [-include [-f <hosts-file> | <comma-separated list of hosts>]]
-
When the include list is non-empty, only the DataNodes specified in the list are balanced by the HDFS Balancer. An empty include list means including all the DataNodes in the cluster. The default value is an empty list.
- [-exclude [-f <hosts-file> | <comma-separated list of hosts>]]
-
The DataNodes specified in the exclude list are excluded so that the HDFS Balancer does not balance those DataNodes. An empty exclude list means that no DataNodes are excluded. When a DataNode is specified in both in the include list and the exclude list, the DataNode is excluded. The default value is an empty list.
Idle-iterations and run during upgrade
- [-idleiterations <idleiterations>]
-
Specifies the number of consecutive iterations in which no blocks have been moved before the HDFS Balancer terminates with the NO_MOVE_PROGRESS exit status.
Specify
-1
for infinite iterations. The default is5
. - [-runDuringUpgrade]
-
If specified, the HDFS Balancer runs even if there is an ongoing HDFS upgrade. If not specified, the HDFS Balancer terminates with the
UNFINALIZED_UPGRADE
exit status.When there is no ongoing upgrade, this option has no effect. It is usually not desirable to run HDFS Balancer during upgrade. To support rollback, blocks being deleted from HDFS are moved to the internal trash directory in DataNodes and not actually deleted. Running the HDFS Balancer during upgrading cannot reduce the usage of any DataNode storage.
Source DataNodes
- [-source [-f <hosts-file> | <comma-separated list of hosts>]]
-
Specifies the source DataNode list. The HDFS Balancer selects blocks to move from only the specified DataNodes. When the list is empty, all the DataNodes are chosen as a source. The option can be used to free up the space of some particular DataNodes in the cluster. Without the -source option, the HDFS Balancer can be inefficient in some cases.
The default value is an empty list.
The following table shows an example, where the average utilization is 25% so that D2 is within the 10% threshold. It is unnecessary to move any blocks from or to D2. Without specifying the source nodes, HDFS Balancer first moves blocks from D2 to D3, D4 and D5, since they are under the same rack, and then moves blocks from D1 to D2, D3, D4 and D5. By specifying D1 as the source node, HDFS Balancer directly moves blocks from D1 to D3, D4 and D5.
Table 1. Example of utilization movement Datanodes (with the same capacity) Utilization Rack D1 95% A D2 30% B D3, D4, and D5 0% B