一、datanode添加新節點
1 在dfs.include文件中包含新節點名稱,該文件在名稱節點的本地目錄下
[白名單]
[s201:/soft/hadoop/etc/hadoop/dfs.include]
2 在hdfs-site.xml文件中添加屬性
<property> <name>dfs.hosts</name> <value>/soft/hadoop/etc/dfs.include.txt</value> </property>
3 在nn上刷新節點
Hdfs dfsadmin -refreshNodes
4 在slaves文件中添加新節點ip(主機名)
5 單獨啟動新節點中的datanode
Hadoop-daemon.sh start datanode
二、datanode退役舊節點
1 添加退役節點的ip到黑名單 dfs.hosts.exclude,不要更新白名單
[/soft/hadoop/etc/dfs.hosts.exclude]
2 配置hdfs-site.xml
<property> <name>dfs.hosts.exclude</name> <value>/soft/hadoop/etc/dfs.hosts.exclude.txt</value> </property>
3 刷新nn的節點
hdfs dfsadmin -refreshNodes
4 查看WEBUI,節點狀態在Decommission In Progress
5 當所有的要退役的節點都報告為Decommissioned,數據轉移工作已經完成
6 從白名單刪除節點,並刷新節點
hdfs dfsadmin -refreshNodes
yarn rmadmin -refreshNodes
7 從slaves文件中刪除退役的節點
8 hdfs-site.xml文件內容
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. --> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>dfs.replication</name> <value>3</value> </property> <property> <name>dfs.name.dir</name> <value>/soft/hadoop/name/</value> </property> <property> <name>dfs.data.dir</name> <value>/soft/hadoop/data</value> </property> <property> <name>dfs.namenode.fs-limits.min-block-size</name> <value>1024</value> </property> <property> <name>dfs.hosts.exclude</name> <value>/soft/hadoop/etc/dfs.hosts.exclude.txt</value> </property> </configuration>
三、黑白名單組合結構
Include //dfs.hosts
Exclude //dfs.hosts.exclude
白名單 | 黑名單 | 組合結構 |
No | No | Node may not connect |
No | Yes | Node may not connect |
Yes | No | Node may connect |
Yes | Yes | Node may connect and will be decommissioned |
四、圖文
黑名單文件
刷新節點信息
退役中
五、yarn添加新節點
1 在dfs.include文件中包含新節點名稱,該文件在名稱節點的本地目錄下
[白名單]
[s201:/soft/hadoop/etc/hadoop/dfs.include]
2 在yarn-site.xml文件中添加屬性
<property> <name>yarn.resourcemanager.nodes.include-path</name> <value>/soft/hadoop/etc/dfs.include.txt</value> </property>
3 在rm上刷新節點
yarn rmadmin-refreshNodes
4 在slaves文件中添加新節點ip(主機名)
5 單獨啟動新節點中的資源管理器
yarn-daemon.sh start nodemanager
六、yarn退役新節點
1 添加退役節點的ip到黑名單 dfs.hosts.exclude,不要更新白名單
[/soft/hadoop/etc/dfs.hosts.exclude]
2 配置yarn-site.xml
<property>
<name>yarn-resourcemanager.nodes.exclude-path</name>
<value>/soft/hadoop/etc/dfs.hosts.exclude.txt</value>
</property>
3 刷新rm的節點
yarn rmadmin -refreshNodes
4 查看WEBUI,節點狀態在Decommission In Progress
5 當所有的要退役的節點都報告為Decommissioned,數據轉移工作已經完成
6 從白名單刪除節點,並刷新節點
yarn rmadmin -refreshNodes
7 從slaves文件中刪除退役的節點
注意:因為退役的時候副本數沒有改變。所以要在退役的時候增加新的節點,只是做退役的話,因為不滿足最小副本數要求,一直會停留在退役中,如果想更快的退役的話要使得退役后的副本數仍然達到最小副本數要求。