The balancer is a tool that balances disk space usage on an HDFS cluster when some
datanodes become full or when new empty nodes join the cluster. The tool is deployed as
an application program that can be run by the cluster administrator on a live HDFS
cluster while application adding and deleting files.
SYNOPSIS
To start:
bin/start-balancer.sh [-threshold <threshold>]
Example: bin/ start-balancer.sh
start the balancer with a default threshold of 10%
bin/ start-balancer.sh -threshold 5
start the balancer with a threshold of 5%
To stop:
bin/ stop-balancer.sh
DESCRIPTION
The threshold parameter is a fraction in the range of (0%, 100%) with a default value of
10%. The threshold sets a target for whether the cluster is balanced. A cluster is balanced
if for each datanode, the utilization of the node (ratio of used space at the node to total
capacity of the node) differs from the utilization of the cluster (ratio of used space in the
cluster to total capacity of the cluster) by no more than the threshold value. The smaller
the threshold, the more balanced a cluster will become. It takes more time to run the
balancer for small threshold values. Also for a very small threshold the cluster may not be
able to reach the balanced state when applications write and delete files concurrently.
The tool moves blocks from highly utilized datanodes to poorly utilized datanodes
iteratively. In each iteration a datanode moves or receives no more than the lesser of 10G
bytes or the threshold fraction of its capacity. Each iteration runs no more than 20
minutes. At the end of each iteration, the balancer obtains updated datanodes information
from the namenode.
A system property that limits the balancer’s use of bandwidth is defined in the default
configuration file:
<property>
<name>dfs.balance.bandwidthPerSec</name>
<value>1048576</value>
<description> Specifies the maximum bandwidth that each datanode can utilize for the
balancing purpose in term of the number of bytes per second. </description>
</property>
This property determines the maximum speed at which a block will be moved from one
datanode to another. The default value is 1MB/s. The higher the bandwidth, the faster a
cluster can reach the balanced state, but with greater competition with application
processes. If an administrator changes the value of this property in the configuration file,
the change is observed when HDFS is next restarted.
最开始我们配置的是20m/S
<property>
<name>dfs.balance.bandwidthPerSec</name>
<value>20971520</value>
<description> Specifies the maximum bandwidth that each datanode can utilize for the balancing purpose in term of the number of bytes per second. </description>
</property>