添加白名单
102上创建dfs.hosts文件
[root@hadoop102 hadoop]# pwd
/opt/module/hadoop-2.8.2/etc/hadoop
[root@hadoop102 hadoop]# touch dfs.hosts
[root@hadoop102 hadoop]# vi dfs.hosts
添加白名单机器名称
hadoop102
hadoop103
hadoop104
修改hdfs-site.xml,使白名单生效
[root@hadoop102 hadoop]# vi hdfs-site.xml
<property>
<name>dfs.hosts</name>
<value>/opt/module/hadoop-2.8.2/etc/hadoop/dfs.hosts</value>
</property>
配置分发
[root@hadoop102 hadoop]# xsync hdfs-site.xml
刷新NameNode
[root@hadoop102 hadoop]# hdfs dfsadmin -refreshNodes
更新ResourceManager
[root@hadoop102 hadoop]# yarn rmadmin -refreshNodes
如果数据不平衡,可以用命令实现集群再平衡
[root@hadoop102 sbin]# start-balancer.sh
黑名单
102上创建dfs.hosts.exclude文件,添加退役的机器名称
[root@hadoop102 hadoop-2.8.2]# cd etc/hadoop/
[root@hadoop102 hadoop]# touch dfs.hosts.exclude
[root@hadoop102 hadoop]# vi dfs.hosts.exclude
hadoopexit
修改hdfs-site.xml,使黑名单生效
[root@hadoop102 hadoop]# vi hdfs-site.xml
<property>
<name>dfs.hosts.exclude</name>
<value>/opt/module/hadoop-2.8.2/etc/hadoop/dfs.hosts.exclude</value>
</property>
刷新NameNode、ResourceManager,然后把退役的机器上节点正常退出。