hadoop删除节点
2018-12-02 本文已影响3人
宁君26
现在有hadoop1 ,hadoop2,hadoop3.hadoop4.
要删除hadoop4节点.
1)在namenode的/opt/module/hadoop-2.7.2/etc/hadoop目录下创建dfs.hosts.exclude文件
(hadoop1上)
[atguigu@hadoop1 hadoop]$ pwd
/opt/module/hadoop-2.7.2/etc/hadoop
[atguigu@hadoop1 hadoop]$ touch dfs.hosts.exclude
[atguigu@hadoop1 hadoop]$ vi dfs.hosts.exclude
添加如下主机名称(要退役的节点)
Hadoop4
2)在namenode的hdfs-site.xml配置文件中增加dfs.hosts.exclude属性(hadoop1上)
<property>
<name>dfs.hosts.exclude</name>
<value>/opt/module/hadoop-2.7.2/etc/hadoop/dfs.hosts.exclude</value>
</property>
3)刷新namenode、刷新resourcemanager
[atguigu@hadoop1 hadoop-2.7.2]$ hdfs dfsadmin -refreshNodes
Refresh nodes successful
[atguigu@hadoop1 hadoop-2.7.2]$ yarn rmadmin -refreshNodes
17/06/24 14:55:56 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.1.103:8033
4)检查web浏览器,退役节点的状态为decommission in progress(退役中),说明数据节点正在复制块到其他节点。
5)等待退役节点状态为decommissioned(所有块已经复制完成),停止该节点及节点资源管理器。注意:如果副本数是3,服役的节点小于等于3,是不能退役成功的,需要修改副本数后才能退役。
[atguigu@hadoop4 hadoop-2.7.2]$ sbin/hadoop-daemon.sh stop datanode
stopping datanode
[atguigu@hadoop4 hadoop-2.7.2]$ sbin/yarn-daemon.sh stop nodemanager
stopping nodemanager
6)从include文件中删除退役节点,再运行刷新节点的命令
(1)从namenode的dfs.hosts文件中删除退役节点hadoop105
hadoop1
hadoop2
hadoop3
(2)刷新namenode,刷新resourcemanager
[atguigu@hadoop1 hadoop-2.7.2]$ hdfs dfsadmin -refreshNodes
Refresh nodes successful
[atguigu@hadoop1 hadoop-2.7.2]$ yarn rmadmin -refreshNodes
17/06/24 14:55:56 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.1.103:8033
7)从namenode的slave文件中删除退役节点hadoop4
hadoop1
hadoop2
hadoop3
8)如果数据不均衡,可以用命令实现集群的再平衡
[atguigu@hadoop1 hadoop-2.7.2]$ sbin/start-balancer.sh
starting balancer, logging to /opt/module/hadoop-2.7.2/logs/hadoop-atguigu-balancer-hadoop102.out
Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved