HDFS在CentOS上的负载均衡实现指南
一 数据面均衡 Balancer
hdfs dfsadmin -report 查看 Capacity/Used/Remaining 与节点状态。hdfs balancer -statushdfs balancer -threshold 10(差异不超过**10%**时停止)hdfs dfsadmin -setBalancerBandwidth 10485760(单位:字节/秒,示例为10MB/s)<property>
<name>dfs.datanode.balance.bandwidthPerSec</name>
<value>10485760</value>
</property>
<property>
<name>dfs.datanode.balance.max-concurrent-moves</name>
<value>10</value>
</property>
<property>
<name>dfs.datanode.balance.threadpool.size</name>
<value>10</value>
</property>
hdfs balancer -threshold 5hdfs balancer -policy blockpoolhdfs balancer -include/-exclude -f nodes.listtail -f /var/log/hadoop-hdfs/hadoop-hdfs-balancer-*.log0 * * * * /usr/local/hadoop/bin/hdfs balancer -threshold 10二 控制面均衡 NameNode请求分发
global
log /dev/log local0
log /dev/log local1 notice
daemon
defaults
log global
mode tcp
option tcplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend hdfs_namenode_rpc
bind *:8020
default_backend nn_rpc_back
backend nn_rpc_back
balance roundrobin
server nn1 192.168.1.11:8020 check
server nn2 192.168.1.12:8020 check
systemctl start haproxy && systemctl enable haproxy<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://your-lb-host:8020</value>
</property>
</configuration>
三 关键注意事项与最佳实践
hdfs dfsadmin -decommission 再下线,避免 Balancer 反复搬迁。四 快速排错清单