美文网首页
服役新结点&退役旧结点

服役新结点&退役旧结点

作者: ae601c79c4fc | 来源:发表于2019-07-28 14:29 被阅读0次

    服役新结点

    1. 环境准备
      克隆一台和原来一模一样的机器(环境要相同)
      注意:
      ①修IP地址和主机名称
      ②删除原来HDFS文件系统留存的文件(/opt/module/hadoop-2.7.2/data和log)
    2. 服役新节点具体步骤
      (1)直接启动DataNode,即可关联到集群
    [zby@hadoop105 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start datanode
    [zby@hadoop105 hadoop-2.7.2]$ sbin/yarn-daemon.sh start nodemanager
    

    (2)如果数据不均衡,可以用命令实现集群的再平衡

    [zby@hadoop102 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
    

    退役旧结点

    方法一:添加白名单

    添加到白名单的主机节点,都允许访问NameNode,不在白名单的主机节点,都会被退出。
    配置白名单的具体步骤如下:
    (1)在NameNode的/opt/module/hadoop-2.7.2/etc/hadoop目录下创建dfs.hosts文件

    [zby@hadoop102 hadoop]$ pwd
    /opt/module/hadoop-2.7.2/etc/hadoop
    [zby@hadoop102 hadoop]$ touch dfs.hosts
    [zby@hadoop102 hadoop]$ vi dfs.hosts
    

    添加如下主机名称(不添加hadoop105)

    hadoop102
    hadoop103
    hadoop104
    

    (2)在NameNode的hdfs-site.xml配置文件中增加dfs.hosts属性

    <property>
    <name>dfs.hosts</name>
    <value>/opt/module/hadoop-2.7.2/etc/hadoop/dfs.hosts</value>
    </property>
    

    (3)配置文件分发

    [zby@hadoop102 hadoop]$ xsync hdfs-site.xml
    

    (4)刷新NameNode

    [zby@hadoop102 hadoop-2.7.2]$ hdfs dfsadmin -refreshNodes
    Refresh nodes successful
    

    (5)更新ResourceManager节点

    [zby@hadoop102 hadoop-2.7.2]$ yarn rmadmin -refreshNodes
    17/06/24 14:17:11 INFO client.RMProxy: Connecting to ResourceManager at hadoop103/192.168.1.103:8033
    

    (6)如果数据不均衡,可以用命令实现集群的再平衡

    [zby@hadoop102 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
    

    方法二:添加黑名单

    在黑名单上面的主机都会被强制退出。

    1. 在NameNode的/opt/module/hadoop-2.7.2/etc/hadoop目录下创建dfs.hosts.exclude文件
    [zby@hadoop102 hadoop]$ pwd
    /opt/module/hadoop-2.7.2/etc/hadoop
    [zby@hadoop102 hadoop]$ touch dfs.hosts.exclude
    [zby@hadoop102 hadoop]$ vi dfs.hosts.exclude
    

    添加如下主机名称(要退役的节点)

    hadoop105
    
    1. 在NameNode的hdfs-site.xml配置文件中增加dfs.hosts.exclude属性
    <property>
    <name>dfs.hosts.exclude</name
     <value>/opt/module/hadoop-2.7.2/etc/hadoop/dfs.hosts.exclude</value>
    </property>
    
    1. 刷新NameNode、刷新ResourceManager
    [zby@hadoop102 hadoop-2.7.2]$ hdfs dfsadmin -refreshNodes
    Refresh nodes successful
    [zby@hadoop102 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
    
    1. 检查Web浏览器,退役节点的状态为decommission in progress(退役中),说明数据节点正在复制块到其他节点,如下图所示


      退役中.jpg
    2. 等待退役节点状态为decommissioned(所有块已经复制完成),停止该节点及节点资源管理器。注意:如果副本数是3,服役的节点小于等于3,是不能退役成功的,需要修改副本数后才能退役,如下图所示


      已退役.jpg
    3. 如果数据不均衡,可以用命令实现集群的再平衡
    [zby@hadoop102 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
    

    注意:不允许白名单和黑名单中同时出现同一个主机名称。最好用添加黑名单的方式来退役旧结点!

    相关文章

      网友评论

          本文标题:服役新结点&退役旧结点

          本文链接:https://www.haomeiwen.com/subject/fhaurctx.html