線上上的hadoop叢集營運過程中,hadoop 的balance工具通常用於平衡hadoop叢集中各datanode中的檔案塊分布,以避免出現部分datanode磁碟佔用率高的問題(這問題也很有可能導致該節點CPU使用率較其他伺服器高)。
1) hadoop balance工具的用法:
To start:bin/start-balancer.sh [-threshold <threshold>]Example: bin/ start-balancer.shstart the balancer with a default threshold of 10%bin/ start-balancer.sh -threshold 5start the balancer with a threshold of 5%To stop:bin/ stop-balancer.sh
2)影響hadoop balance工具的幾個參數:
-threshold 預設設定:10,參數取值範圍:0-100,參數含義:判斷叢集是否平衡的目標參數,每一個 datanode 儲存使用率和叢集總儲存使用率的差值都應該小於這個閥值 ,理論上,該參數設定的越小,整個叢集就越平衡,但是線上上環境中,hadoop叢集在進行balance時,還在並發的進行資料的寫入和刪除,所以有可能無法到達設定的平衡參數值。
dfs.balance.bandwidthPerSec 預設設定:1048576(1 M/S),參數含義:設定balance工具在運行中所能佔用的頻寬,設定的過大可能會造成mapred運行緩慢
3)hadoop balance工具其他特點:
balance工具在運行過程中,迭代的將檔案塊從高使用率的datanode移動到低使用率的datanode上,每一個迭代過程中移動的資料量不超過下面兩個值的較小者:10G或者指定閥值*容量,且每次迭代不超過20分鐘。每次迭代結束後,balance工具將更新該datanode的檔案塊分布情況。以下為官方文檔英文描述:
The tool moves blocks from highly utilized datanodes to poorly utilized datanodesiteratively. In each iteration a datanode moves or receives no more than the lesser of 10Gbytes or the threshold fraction of its capacity. Each iteration runs no more than 20minutes. At the end of each iteration, the balancer obtains updated datanodes informationfrom the namenode.