1、背景

当我们的hadoop集群运行了一段时间之后,各个DataNode上的数据分布不一定均匀分布的。比如说: 我们向现有集群中添加了一个新的DataNode。

2、什么是平衡

此处是我自己的一个简单的理解

所谓的平衡指的是 每个DataNode的利用率集群的利用率 之间相差不超过给定的阈值百分比。此处的平衡 指的是各个DataNode之间的平衡,同一个DataNode之间的各个磁盘是不会平衡的。

2.1 每个DataNode的利用率计算



DataNode的利用率= dfs已用的空间 / 分配给dfs的空间。

注意: 分配给dfs的空间 不是磁盘的总空间。

2.2 集群的利用率



集群的利用率= 各datanode dfs已使用的空间 / 各datanode总空间

2.3 平衡

假设平衡的阈值是 5%,集群的利用率是 37.5,那么每个节点的利用率在32.5%42.5%之间都认为是均衡的。也就是说,极端情况下,DataNode的利用率最大相差10%

3、hdfs balancer语法

  1. [hadoopdeploy@hadoop01 ~]$ hdfs balancer --help
  2. Usage: hdfs balancer
  3. [-policy <policy>] the balancing policy: datanode or blockpool
  4. [-threshold <threshold>] Percentage of disk capacity
  5. [-exclude [-f <hosts-file> | <comma-separated list of hosts>]] Excludes the specified datanodes.
  6. [-include [-f <hosts-file> | <comma-separated list of hosts>]] Includes only the specified datanodes.
  7. [-source [-f <hosts-file> | <comma-separated list of hosts>]] Pick only the specified datanodes as source nodes.
  8. [-blockpools <comma-separated list of blockpool ids>] The balancer will only run on blockpools included in this list.
  9. [-idleiterations <idleiterations>] Number of consecutive idle iterations (-1 for Infinite) before exit.
  10. [-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.
  11. [-asService] Run as a long running service.
  12. Generic options supported are:
  13. -conf <configuration file> specify an application configuration file
  14. -D <property=value> define a value for a given property
  15. -fs <file:///|hdfs://namenode:port> specify default filesystem URL to use, overrides 'fs.defaultFS' property from configurations.
  16. -jt <local|resourcemanager:port> specify a ResourceManager
  17. -files <file1,...> specify a comma-separated list of files to be copied to the map reduce cluster
  18. -libjars <jar1,...> specify a comma-separated list of jar files to be included in the classpath
  19. -archives <archive1,...> specify a comma-separated list of archives to be unarchived on the compute machines
  20. The general command line syntax is:
  21. command [genericOptions] [commandOptions]
参数 描述
threshold 磁盘容量的百分比。默认值为10%,表示上下浮动10%。
policy 平衡策略。
datanode(默认):当每一个DataNode是平衡的时候,集群就是平衡的。
blockpool:当每一个DataNode中的blockpool是平衡的,集群就是平衡的。
exclude 不参与平衡的DataNode节点
include 参与平衡的DataNode节点
source 仅选取指定的数据节点作为源节点
blockpools Balancer仅在指定的blockpools中运行
idleiterations 退出前的连续空闲迭代次数(-1表示无限)
-runDuringUpgrade 是否在正在进行的HDFS升级过程中运行平衡器。通常不需要这样做,因为这不会影响过度使用的计算机上的已用空间。
-asService 作为长期运行的服务运行

4、运行一个简单的balance案例

4.1 设置平衡数据传输带宽

  1. [hadoopdeploy@hadoop01 ~]$ hdfs dfsadmin -setBalancerBandwidth 10485760
  2. Balancer bandwidth is set to 10485760
  3. [hadoopdeploy@hadoop01 ~]$

当我们的集群负载需要调低这个值,当我们的集群负载较低时,可以适当调高这个值。

4.2 执行banalce

  1. [hadoopdeploy@hadoop01 ~]$ hdfs balancer -policy datanode -threshold 5
  2. 2023-03-26 14:10:09,785 INFO balancer.Balancer: Using a threshold of 5.0
  3. 2023-03-26 14:10:09,786 INFO balancer.Balancer: namenodes = [hdfs://hadoop01:8020]
  4. 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]
  5. 2023-03-26 14:10:09,786 INFO balancer.Balancer: included nodes = []
  6. 2023-03-26 14:10:09,786 INFO balancer.Balancer: excluded nodes = []
  7. 2023-03-26 14:10:09,786 INFO balancer.Balancer: source nodes = []
  8. Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved NameNode
  9. 2023-03-26 14:10:09,787 INFO balancer.NameNodeConnector: getBlocks calls for hdfs://hadoop01:8020 will be rate-limited to 20 per second
  10. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.namenode.get-blocks.max-qps = 20 (default=20)
  11. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.movedWinWidth = 5400000 (default=5400000)
  12. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.moverThreads = 1000 (default=1000)
  13. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.dispatcherThreads = 200 (default=200)
  14. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.getBlocks.size = 2147483648 (default=2147483648)
  15. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.balancer.getBlocks.min-block-size = 10485760 (default=10485760)
  16. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.datanode.balance.max.concurrent.moves = 100 (default=100)
  17. 2023-03-26 14:10:10,392 INFO balancer.Balancer: dfs.datanode.balance.bandwidthPerSec = 104857600 (default=104857600)
  18. 2023-03-26 14:10:10,395 INFO balancer.Balancer: dfs.balancer.max-size-to-move = 10737418240 (default=10737418240)
  19. 2023-03-26 14:10:10,395 INFO balancer.Balancer: dfs.blocksize = 134217728 (default=134217728)
  20. 2023-03-26 14:10:10,401 INFO net.NetworkTopology: Adding a new node: /default-rack/192.168.121.141:9866
  21. 2023-03-26 14:10:10,401 INFO net.NetworkTopology: Adding a new node: /default-rack/192.168.121.140:9866
  22. 2023-03-26 14:10:10,401 INFO net.NetworkTopology: Adding a new node: /default-rack/192.168.121.142:9866
  23. 2023-03-26 14:10:10,402 INFO balancer.Balancer: 0 over-utilized: []
  24. 2023-03-26 14:10:10,402 INFO balancer.Balancer: 0 underutilized: []
  25. 2023-3-26 14:10:10 0 0 B 0 B 0 B 0 hdfs://hadoop01:8020
  26. The cluster is balanced. Exiting...
  27. 2023-3-26 14:10:10 Balancing took 810.0 milliseconds
  28. [hadoopdeploy@hadoop01 ~]$

5、参考文档

1、https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsUserGuide.html#Balancer

2、https://help.aliyun.com/document_detail/449686.html

HDFS Balancer负载均衡器的更多相关文章

  1. Hadoop记录-HDFS balancer配置

    HDFS balancer配置(可通过CM配置)dfs.datanode.balance.max.concurrent.moves 并行移动的block数量,默认5 dfs.datanode.bala ...

  2. sudo -u hdfs hdfs balancer出现异常 No lease on /system/balancer.id

    16/06/02 20:34:05 INFO balancer.Balancer: namenodes = [hdfs://dlhtHadoop101:8022, hdfs://dlhtHadoop1 ...

  3. 【转】HADOOP HDFS BALANCER介绍及经验总结

    转自:http://www.aboutyun.com/thread-7354-1-1.html 集群平衡介绍 Hadoop的HDFS集群非常容易出现机器与机器之间磁盘利用率不平衡的情况,比如集群中添加 ...

  4. 【转载】漫谈HADOOP HDFS BALANCER

    Hadoop的HDFS集群非常容易出现机器与机器之间磁盘利用率不平衡的情况,比如集群中添加新的数据节点.当HDFS出现不平衡状况的时候,将引发很多问题,比如MR程序无法很好地利用本地计算的优势,机器之 ...

  5. HADOOP HDFS BALANCER介绍及经验总结(转)

    1.集群执行balancer命令,依旧不平衡的原因是什么?该如何解决? 2.尽量不在NameNode上执行start-balancer.sh的原因是什么? 集群平衡介绍 Hadoop的HDFS集群非常 ...

  6. CDH版HDFS Block Balancer方法

    命令: sudo -u hdfs hdfs balancer 默认会检查每个datanode的磁盘使用情况,对磁盘使用超过整个集群10%的datanode移动block到其他datanode达到均衡作 ...

  7. HDFS 上传文件的不平衡,Balancer问题是过慢

    至HDFS上传文件.假定从datanode开始上传文件,上传的数据将导致目前的当务之急是全datanode圆盘.这是一个分布式程序的执行是非常不利. 解决方案: 1.从其他非datanode节点上传 ...

  8. 【转载】HDFS 上传文件不均衡和Balancer太慢的问题

    向HDFS上传文件,如果是从某个datanode开始上传文件,会导致上传的数据优先写满当前datanode的磁盘,这对于运行分布式程序是非常不利的. 解决的办法: 1.从其他非datanode节点上传 ...

  9. hdfs的balancer

    参考: https://blog.csdn.net/mnasd/article/details/80369603 在CDH中选一个资源多的节点,安装 HDFS->添加角色到实例 启动后状态是灰的 ...

  10. Azure PowerShell (8) 使用PowerShell设置Azure负载均衡器规则

    <Windows Azure Platform 系列文章目录> 注意:如果Azure面对的客户只是企业级客户,企业级客户使用NAT设备访问Internet的话,因为多个客户端使用相同的So ...

随机推荐

  1. STC MCU的软件和硬件PCA/PWM输出

    软件方式输出PWM PWM用于输出强度的控制, 例如灯的亮度, 轮子速度等, STC89/90系列没有硬件PWM, 需要使用代码模拟 使用纯循环的方式实现PWM 非中断的实现(SDCC环境编译) #i ...

  2. springboot jpa自定义SQL查询

    说明 在使用JPA实现数据持久化过程中经常会遇到这种情况:我有2张表是一对多的关系,需要通过一个外键ID去关联查询到另外一张表的字段.例如,1张商品表food_info其中存有商品分类ID categ ...

  3. Vue+ElementUI实现用户管理前后分离实战一:前端篇

    项目介绍 前几天有老铁问我能不能写一个Vue+ElementUI+SpringBoot后端的前后分离项目,最近有点忙,但今天他还是来了!希望对大家能有点帮助,大家还想要点啥也可以加我QQ或给我留言 : ...

  4. string 字符串转为 char *

    std::string str = "abc"; const char *p = str.data(); 更多: https://www.cnblogs.com/devilmayc ...

  5. win32 - this 指针

    this指针是存在与类的成员函数中,指向被调用函数所在的类实例的地址. 根据以下程序来说明this指针, #include<iostream.h> class Point { int x, ...

  6. python模块imghdr-----推测图像类型

    官方文档 https://docs.python.org/zh-cn/3/library/imghdr.html#module-imghdr 用处 模块推测文件或字节流中的图像的类型 imghdr.w ...

  7. Elasticsearch系列之-查询

    Elasticsearch之-查询 查询分类: 基本查询:使用es内置查询条件进行查询 组合查询:把多个查询组合在一起进行复合查询 过滤:查询的同时,通过filter条件在不影响打分的情况下筛选数据 ...

  8. Java是解释型语言么

    基础概念 JVM虚拟机会将.java类文件编译成.class文件--字节码文件,这大家都知道. 代码运行时还需要将.class字节码文件翻译成机器码才能执行. 解释执行:将编译好的字节码一行一行地翻译 ...

  9. DataGear 制作支持全国、省、市三级数据钻取效果的地图数据可视化看板

    通过DataGear的参数化数据集.图表联动和看板API功能,可以很方便地制作支持数据钻取效果的数据可视化看板. 首先,以上级地区名为参数,新建一个参数化SQL数据集: SELECT COL_NAME ...

  10. 【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数

    问题描述 在Azure App Service for Windows的环境中,部署.NET应用,其中使用了 SAP NetWeaver RFC函数 (需要加载 sapnwrfc.dll).详细的错误 ...