您好,登錄后才能下訂單哦!
Hadoop 均衡器
Hadoop在運行過程中,其datanode的塊會越來越不平衡,不平衡的集群會導致部分datanode相對更繁忙。
Hadoop的均衡器是一個守護進程。它會重新分配塊,將塊從忙碌的datanode移到相對空閑的datanode。同時堅持復本策略,將復本分散到不同機架,以降低數據損壞率。
集群均衡標準:每個datanode的使用率和集群的使用率非常接近,差距不超過給定的閥值。
datanode使用率:該節點上已使用的空間與空間總量之間的比率;
集群的使用率:集群中已使用的空間與集群的總空間總量之間的比率。
為了降低集群負荷、避免干擾其他用戶,均衡器后臺運行,并限制不同節點之間復制數據的帶寬,默認值為1MB/s。
Hadoop的均衡器默認是關閉的,啟動需要執行%start-balancer.sh,集群均衡后會自動停止。
HBase 負載均衡
HBase的均衡器默認五分鐘執行一次,由 hbase.balancer.period屬性設置。均衡器運行后會嘗試均勻分配region到所有region服務器。
先確定一個region分配計劃,然后開始移動region。
通過均衡器的開關類控制開啟和關閉狀態。
HBase的均衡器默認是開啟的,并周期性運行。
下面是官網的解釋說明:
Over time, the distribution of blocks across datanodes can become unbalanced. An unbalanced cluster can affect locality for MapReduce, and it puts a greater strain on the highly utilized datanodes, so it’s best avoided.
The balancer program is a Hadoop daemon that redistributes blocks by moving them from overutilized datanodes to underutilized datanodes, while adhering to the block replica placement policy that makes data loss unlikely by placing block replicas on different racks (see Replica Placement). It moves blocks until the cluster is deemed to be balanced, which means that the utilization of every datanode (ratio of used space on the node to total capacity of the node) differs from the utilization of the cluster (ratio of used space on the cluster to total capacity of the cluster) by no more than a given threshold percentage. You can start the balancer with:
% start-balancer.sh
The -threshold
argument specifies the threshold percentage that defines what it means for the cluster to be balanced. The flag is optional; if omitted, the threshold is 10%. At any one time, only one balancer may be running on the cluster.
The balancer runs until the cluster is balanced, it cannot move any more blocks, or it loses contact with the namenode. It produces a logfile in the standard log directory, where it writes a line for every iteration of redistribution that it carries out. Here is the output from a short run on a small cluster (slightly reformatted to fit the page):
Time Stamp Iteration# Bytes Already Moved ...Left To Move ...Being Moved
Mar 18, 2009 5:23:42 PM 0 0 KB 219.21 MB 150.29 MB
Mar 18, 2009 5:27:14 PM 1 195.24 MB 22.45 MB 150.29 MB
The cluster is balanced. Exiting...
Balancing took 6.072933333333333 minutes
The balancer is designed to run in the background without unduly taxing the cluster or interfering with other clients using the cluster. It limits the bandwidth that it uses to copy a block from one node to another. The default is a modest 1 MB/s, but this can be changed by setting the dfs.datanode.balance.bandwidthPerSec
property in hdfs-site.xml, specified in bytes.
The master has a built-in feature, called the balancer. By default, the balancer runs every five minutes, and it is configured by the hbase.balancer.period
property. Once the balancer is started, it will attempt to equal out the number of assigned regions per region server so that they are within one region of the average number per server. The call first determines a new assignment plan, which describes which regions should be moved where. Then it starts the process of moving the regions by calling the unassign()
method of the administrative API iteratively.
The balancer has an upper limit on how long it is allowed to run, which is configured using the hbase.balancer.max.balancing
property anddefaults to half of the balancer period value, or two and a half minutes.
You can control the balancer by means of the balancer switch: either use the shell’s balance_switch command to toggle the balancer status between enabled and disabled, or use the balanceSwitch()
API method to do the same. When you disable the balancer, it no longer runs as expected.
The balancer can be explicitly started using the shell’s balancer command, or using the balancer()
API method. The time-controlled invocation mentioned previously calls this method implicitly. It will determine if there is any work to be done and return true
if that is the case. The return value of false
means that it was not able to run the balancer, because either it was switched off, there was no work to be done (all is balanced), or something else was prohibiting the process. One example for this is the region in transition list (see Main page): if there is a region currently in transition, the balancer will be skipped.
Instead of relying on the balancer to do its work properly, you can use the move command and API method to assign regions to other servers. This is useful when you want to control where the regions of a particular table are assigned. See Region Hotspotting for an example.
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。