HDFS Balancer负载均衡器及语法详解
作者:huan1993 发布时间:2023-11-18 18:30:39
标签:HDFS,Balancer,负载均衡器
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语法
[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]
参数 | 描述 |
---|---|
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 设置平衡数据传输带宽
[hadoopdeploy@hadoop01 ~]$ hdfs dfsadmin -setBalancerBandwidth 10485760
Balancer bandwidth is set to 10485760
[hadoopdeploy@hadoop01 ~]$
当我们的集群负载需要调低这个值,当我们的集群负载较低时,可以适当调高这个值。
4.2 执行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、https://www.jb51.net/article/279671.htm
来源:https://juejin.cn/post/7216182763237359673
0
投稿
猜你喜欢
- 一、前言做新应用就是这样,会遇到各种问题,昨天刚解决了加载某一个类时候抛出了 class is not visible from class
- 本文实例为大家分享了Android判断当前App状态的具体实现代码,供大家参考,具体内容如下第一种: /** *判断当前应用程序
- Reflection也就是反射,是Java语言的一个重要特征,我们知道,在使用一个类之前,我们往往都已经创建好它了,比如创建一个类文件,然后
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&
- 这篇文章主要介绍了配置springboot项目使用外部tomcat过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作
- Java连接SQLServer 2008数据库的步骤:1.到微软官方下载jdbc 并解压,得到sqljdbc.jar和sqljdbc4.ja
- 前言项目使用了SpringBoot构建项目。下面对动态调整日志的级别进行记录。从版本 1.5.1 之后就提供了基于 spring-boot-
- 在进行C#程序设计时,用的最多的莫过于string了,但有些时候由于不仔细或者基础的不牢固等因素容易出错,今天本文就来较为详细的总结一下C#
- 本文实例为大家分享了SpringBoot集成kaptcha验证码的具体代码,供大家参考,具体内容如下1.kaptcha相关介绍Kaptcha
- Java在1.5开始引入了注解,目前流行的框架都在用注解,可想而知注解的强大之处。以下通过自定义注解来深入了解java注解。一、创建自定义注
- Mybatis-Plus是一个优秀的Mybatis增强工具,目前更新到3.1.1。Mybatis-Plus原生提供了很多单表操作的方法,极大
- 《IDEA 破解新招 - 无限重置30天试用期》,这种方法适用idea2021以下所有版本,亲测idea2020.3成功激活,其他版本自测吧
- 数独简介数独(shù dú)是源自18世纪瑞士的一种数学游戏。是一种运用纸、笔进行演算的逻辑游戏
- 本文实例为大家分享了java获取不同路径的方法,供大家参考,具体内容如下思路:自定义Button获取DialogManager、AudioM
- jsoup是一个非常好用的html解析工具。使用时需要下载相应的jar包。下面就是我使用jsoup解析html的表格的java源
- paras.xml文件<?xml version="1.0" encoding="UTF-8"
- 本文实例讲述了Java递归基础与递归的宏观语意。分享给大家供大家参考,具体如下:1.什么是递归本质上,将原来的问题,转化为更小的同一问题2.
- 本文实例讲述了WPF中的ListBox实现按块显示元素的方法。分享给大家供大家参考,具体如下:注意:需要设置ListBox的属性 Scrol
- 下面我们来探究Android如何实现关机,重启;在Android中这种操作往往需要管理员级别,或者rootAndroid实现的方式如下几种:
- 1.通过UnityHub安装unityUnityHub下载路径,UnityHub安装按照步骤来就可以了。打开UnityHub,点安装。3.选