- 详细方案
加上新的datanode节点后,需要直接开始做数据的均衡,这个需要一个技巧,就是定点的balance可以加速这个过程。这就需要通过找到topN的节点先做balance。
---#!/bin/bash
source /etc/profile
export PATH=$HADOOP_HOME/bin:$PATH
Bfile=/home/hdfs/sh/balancer_hosts_raw
Bfile2=/home/hdfs/sh/balancer_hosts
startBalancer(){
jps|grep Balancer
if [ $? -eq 0 ];then
echo "balancer still runing!!"
exit 2
fi
# get top and bottom 30 hosts to be balancing
hdfs dfsadmin -report -live -top 30| grep dfsUsed > $Bfile
cat $Bfile | awk -F "'" '{print $1}' > $Bfile2
# Set Balancer Bandwidth to 500M
hdfs dfsadmin -setBalancerBandwidth 8194304000
## start balancer
start-balancer.sh -threshold 5 -include -f /home/hdfs/sh/balancer_hosts
}
stopB(){
stop-balancer.sh
}```
# 未来工作
到了hadoop 3之后,可以做disk粒度的balance。这种应用场景在于旧磁盘换新后,需要做数据均衡。



