HDFS Disk Balancer 介绍&使用

一、介绍

一句话介绍:用于HDFS DataNode单节点内多个数据盘数据均衡。
官网介绍如下:

Diskbalancer is a command line tool that distributes data evenly on all disks of a datanode. This tool is different from Balancer which takes care of cluster-wide data balancing. Data can have uneven spread between disks on a node due to several reasons. This can happen due to large amount of writes and deletes or due to a disk replacement. This tool operates against a given datanode and moves blocks from one disk to another. [1]

Diskbalancer是一个命令行工具,用于在数据节点的所有磁盘上均匀分布数据。这个工具与Balancer不同,Balancer负责整个集群的数据平衡。由于多种原因,数据在节点的磁盘之间可能分布不均匀。这可能是由于大量的写入和删除,或者由于磁盘替换引起的。该工具针对给定的数据节点操作,并将数据块从一个磁盘移动到另一个磁盘。
传送门:HDFS Balancer //todo

二、配置

dfs.disk.balancer.enabled = true 默认开启,此功能需要hadoop版本大于等于3.0
如需显式配置如下
hdfs-site.xml配置

<property>
   <name>dfs.disk.balancer.enabled</name>
   <value>true</value>
</property>

CDH配置: hdfs-site.xml 的 HDFS 服务高级配置代码段

三、使用

hdfs diskbalancer
...
...
valid commands are plan | execute | query | cancel | report

3.1 创建balance计划-plan

hdfs diskbalancer -plan cdh-01.magic.com \
-bandwidth 100 \
-maxerror 5 \
-thresholdPercentage 5 \
-out /data/tmp/disk-balance/cdh01

参数介绍:
-bandwidth 平衡带宽,单位MB/s,默认10
-maxerror 错误重试次数,默认5
-thresholdPercentage 平衡阈值,默认10,即磁盘占用率大小相差<=10%则认为是平衡的
-out 执行计划json输出路径,注意为hdfs路径,且路径需要为空
执行输出:
会提示生成计划json的路径 如:/data/tmp/disk-balance/cdh01/cdh-01.magic.com.plan.json

3.2 执行计划-execute

hdfs diskbalancer -execute /data/tmp/disk-balance/cdh01/cdh-01.magic.com.plan.json

3.3 查看计划状态-query

hdfs diskbalancer -query cdh-01.magic.com

正常的两种状态
PLAN_UNDER_PROGRESS 处理中
PLAN_DONE 处理完成

3.4 取消执行计划-cancel

hdfs diskbalancer -cancel /data/tmp/disk-balance/cdh01/cdh-01.magic.com.plan.json

3.5 查看执行的报告信息-report

hdfs diskbalancer -report -node cdh-01.magic.com

# 其他格式
hdfs diskbalancer -fs http://namenode.uri -report -node <file://> | [<DataNodeID|IP|Hostname>,...]
hdfs diskbalancer -fs http://namenode.uri -report -top topnum

[1] 官网引用: ​​https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HDFSDiskbalancer.html​​

posted @ 2023-08-30 17:56  magic_guan  阅读(257)  评论(0编辑  收藏  举报