hdfs 重新均衡分配文件有两种方式
1. 命令方式
hdfs balancer 参数说明
[-threshold <threshold>] #均衡阈值,这次先以20%,均衡后每个datanode在容量相差在20%以内。等待第一次均衡后后面再进行一次10%的均衡,降低集群占用时间
[-policy <policy>] # datanode,blockpool 默认datanode,以datanode级别均衡,blockpool文件块均衡(更精准,但更费时),
[-exclude [-f <hosts-file> | <comma-separated list of hosts>]] #排出指定机器
[-include [-f <hosts-file> | <comma-separated list of hosts>]] #添加指定机器
[-idleiterations <idleiterations>] #最大迭代次数
su hdfs -c "hdfs balancer -threshold 20"
缺点:
- 需等待结束,也可以后台执行
2. 脚本方式
执行步骤
- 修改参数 , bsm中在hdfs模块配置自定义hdfs-site.xml文件新增属性dfs.datanode.balance.max.concurrent.moves=50
- 滚动重启datanode
- 切换用户su hdfs
- 设置每台datanode的带宽
hdfs dfsadmin -setBalancerBandwidth 73400320 - 开始平衡 /opt/hadoop/sbin/start-balancer.sh -threshold 40
- 观察日志,跟上面命令返回的out 文件同一目录
网友评论