HDFS?Balancer負(fù)載均衡器及語法詳解
1、背景
當(dāng)我們的hadoop集群運(yùn)行了一段時(shí)間之后,各個(gè)DataNode上的數(shù)據(jù)分布并不一定是均勻分布的。比如說: 我們向現(xiàn)有集群中添加了一個(gè)新的DataNode。

2、什么是平衡
此處是我自己的一個(gè)簡單的理解
所謂的平衡指的是 每個(gè)DataNode的利用率 與 集群的利用率 之間相差不超過給定的閾值百分比。此處的平衡 指的是各個(gè)DataNode之間的平衡,同一個(gè)DataNode之間的各個(gè)磁盤是不會平衡的。
2.1 每個(gè)DataNode的利用率計(jì)算

DataNode的利用率= dfs已用的空間 / 分配給dfs的空間。
注意: 分配給dfs的空間 不是磁盤的總空間。
2.2 集群的利用率

集群的利用率= 各datanode dfs已使用的空間 / 各datanode總空間
2.3 平衡
假設(shè)平衡的閾值是 5%,集群的利用率是 37.5,那么每個(gè)節(jié)點(diǎn)的利用率在32.5%到42.5%之間都認(rèn)為是均衡的。也就是說,極端情況下,DataNode的利用率最大相差10%。
3、hdfs balancer語法
[hadoopdeploy@hadoop01 ~]$ hdfs balancer --help Usage: hdfs balancer [-policy <policy>] the balancing policy: datanode or blockpool [-threshold <threshold>] Percentage of disk capacity [-exclude [-f <hosts-file> | <comma-separated list of hosts>]] Excludes the specified datanodes. [-include [-f <hosts-file> | <comma-separated list of hosts>]] Includes only the specified datanodes. [-source [-f <hosts-file> | <comma-separated list of hosts>]] Pick only the specified datanodes as source nodes. [-blockpools <comma-separated list of blockpool ids>] The balancer will only run on blockpools included in this list. [-idleiterations <idleiterations>] Number of consecutive idle iterations (-1 for Infinite) before exit. [-runDuringUpgrade] Whether to run the balancer during an ongoing HDFS upgrade.This is usually not desired since it will not affect used space on over-utilized machines. [-asService] Run as a long running service. Generic options supported are: -conf <configuration file> specify an application configuration file -D <property=value> define a value for a given property -fs <file:///|hdfs://namenode:port> specify default filesystem URL to use, overrides 'fs.defaultFS' property from configurations. -jt <local|resourcemanager:port> specify a ResourceManager -files <file1,...> specify a comma-separated list of files to be copied to the map reduce cluster -libjars <jar1,...> specify a comma-separated list of jar files to be included in the classpath -archives <archive1,...> specify a comma-separated list of archives to be unarchived on the compute machines The general command line syntax is: command [genericOptions] [commandOptions]
| 參數(shù) | 描述 |
|---|---|
| threshold | 磁盤容量的百分比。默認(rèn)值為10%,表示上下浮動10%。 |
| policy | 平衡策略。 datanode(默認(rèn)):當(dāng)每一個(gè)DataNode是平衡的時(shí)候,集群就是平衡的。 blockpool:當(dāng)每一個(gè)DataNode中的blockpool是平衡的,集群就是平衡的。 |
| exclude | 不參與平衡的DataNode節(jié)點(diǎn) |
| include | 參與平衡的DataNode節(jié)點(diǎn) |
| source | 僅選取指定的數(shù)據(jù)節(jié)點(diǎn)作為源節(jié)點(diǎn) |
| blockpools | Balancer僅在指定的blockpools中運(yùn)行 |
| idleiterations | 退出前的連續(xù)空閑迭代次數(shù)(-1表示無限) |
| -runDuringUpgrade | 是否在正在進(jìn)行的HDFS升級過程中運(yùn)行平衡器。通常不需要這樣做,因?yàn)檫@不會影響過度使用的計(jì)算機(jī)上的已用空間。 |
| -asService | 作為長期運(yùn)行的服務(wù)運(yùn)行 |
4、運(yùn)行一個(gè)簡單的balance案例
4.1 設(shè)置平衡數(shù)據(jù)傳輸帶寬
[hadoopdeploy@hadoop01 ~]$ hdfs dfsadmin -setBalancerBandwidth 10485760 Balancer bandwidth is set to 10485760 [hadoopdeploy@hadoop01 ~]$
當(dāng)我們的集群負(fù)載需要調(diào)低這個(gè)值,當(dāng)我們的集群負(fù)載較低時(shí),可以適當(dāng)調(diào)高這個(gè)值。
4.2 執(zhí)行banalce
[hadoopdeploy@hadoop01 ~]$ hdfs balancer -policy datanode -threshold 5 2023-03-26 14:10:09,785 INFO balancer.Balancer: Using a threshold of 5.0 2023-03-26 14:10:09,786 INFO balancer.Balancer: namenodes = [hdfs://hadoop01:8020] 2023-03-26 14:10:09,786 INFO balancer.Balancer: parameters = Balancer.BalancerParameters [BalancingPolicy.Node, threshold = 5.0, max idle iteration = 5, #excluded nodes = 0, #included nodes = 0, #source nodes = 0, #blockpools = 0, run during upgrade = false] 2023-03-26 14:10:09,786 INFO balancer.Balancer: included nodes = [] 2023-03-26 14:10:09,786 INFO balancer.Balancer: excluded nodes = [] 2023-03-26 14:10:09,786 INFO balancer.Balancer: source nodes = [] Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved NameNode 2023-03-26 14:10:09,787 INFO balancer.NameNodeConnector: getBlocks calls for hdfs://hadoop01:8020 will be rate-limited to 20 per second 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.namenode.get-blocks.max-qps = 20 (default=20) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.movedWinWidth = 5400000 (default=5400000) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.moverThreads = 1000 (default=1000) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.dispatcherThreads = 200 (default=200) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.getBlocks.size = 2147483648 (default=2147483648) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.getBlocks.min-block-size = 10485760 (default=10485760) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.datanode.balance.max.concurrent.moves = 100 (default=100) 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.datanode.balance.bandwidthPerSec = 104857600 (default=104857600) 2023-03-26 14:10:10,395 INFO balancer.Balancer: dfs.balancer.max-size-to-move = 10737418240 (default=10737418240) 2023-03-26 14:10:10,395 INFO balancer.Balancer: dfs.blocksize = 134217728 (default=134217728) 2023-03-26 14:10:10,401 INFO net.NetworkTopology: Adding a new node: /default-rack/192.168.121.141:9866 2023-03-26 14:10:10,401 INFO net.NetworkTopology: Adding a new node: /default-rack/192.168.121.140:9866 2023-03-26 14:10:10,401 INFO net.NetworkTopology: Adding a new node: /default-rack/192.168.121.142:9866 2023-03-26 14:10:10,402 INFO balancer.Balancer: 0 over-utilized: [] 2023-03-26 14:10:10,402 INFO balancer.Balancer: 0 underutilized: [] 2023-3-26 14:10:10 0 0 B 0 B 0 B 0 hdfs://hadoop01:8020 The cluster is balanced. Exiting... 2023-3-26 14:10:10 Balancing took 810.0 milliseconds [hadoopdeploy@hadoop01 ~]$
5、參考文檔
1、hadoop.apache.org/docs/curren…
2、http://www.dhdzp.com/article/279671.htm
以上就是HDFS Balancer負(fù)載均衡器及語法詳解的詳細(xì)內(nèi)容,更多關(guān)于HDFS Balancer負(fù)載均衡器的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Spring下Filter過濾器配置全局異常處理的詳細(xì)步驟
這篇文章主要介紹了Spring下Filter過濾器配置全局異常處理的詳細(xì)步驟,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12
SpringBoot整合Redis實(shí)現(xiàn)消息發(fā)布與訂閱的示例代碼
能實(shí)現(xiàn)發(fā)送與接收信息的中間介有很多,比如:RocketMQ、RabbitMQ、ActiveMQ、Kafka等,本文主要介紹了Redis的推送與訂閱功能并集成Spring Boot的實(shí)現(xiàn),感興趣的可以了解一下2022-08-08
springboot與springmvc基礎(chǔ)入門講解
本篇文章主要介紹了詳解快速搭建Spring Boot+Spring MVC,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2021-07-07
SpringBoot如何使用Template請求http接口
在Spring?Boot中,如果你想要通過模板(template)的方式連接HTTP服務(wù),并發(fā)送HTTP請求,有幾種不同的方式可以實(shí)現(xiàn),但最直接和常用的方式之一是使用RestTemplate,這篇文章主要介紹了SpringBoot使用Template請求http接口,需要的朋友可以參考下2024-08-08
Java 中如何使用 JavaFx 庫標(biāo)注文本顏色
這篇文章主要介紹了在 Java 中用 JavaFx 庫標(biāo)注文本顏色,在本文中,我們將了解如何更改標(biāo)簽的文本顏色,并且我們還將看到一個(gè)必要的示例和適當(dāng)?shù)慕忉?,以便更容易理解該主題,需要的朋友可以參考下2023-05-05
Java連接合并2個(gè)數(shù)組(Array)的5種方法例子
最近在寫代碼時(shí)遇到了需要合并兩個(gè)數(shù)組的需求,突然發(fā)現(xiàn)以前沒用過,于是研究了一下合并數(shù)組的方式,這篇文章主要給大家介紹了關(guān)于Java連接合并2個(gè)數(shù)組(Array)的5種方法,需要的朋友可以參考下2023-12-12
hibernate 中 fetch=FetchType.LAZY 懶加載失敗處理方法
這篇文章主要介紹了hibernate 中 fetch=FetchType.LAZY 懶加載失敗處理方法,需要的朋友可以參考下2017-09-09
基于Java的度分秒坐標(biāo)轉(zhuǎn)純經(jīng)緯度坐標(biāo)的漂亮國基地信息管理的方法
本文以java語言為例,詳細(xì)介紹如何管理漂亮國的基地信息,為下一步全球的空間可視化打下堅(jiān)實(shí)的基礎(chǔ),首先介紹如何對數(shù)據(jù)進(jìn)行去重處理,然后介紹在java當(dāng)中如何進(jìn)行度分秒位置的轉(zhuǎn)換,最后結(jié)合實(shí)現(xiàn)原型進(jìn)行詳細(xì)的說明,感興趣的朋友跟隨小編一起看看吧2024-06-06

