[关闭]
@nalan90 2017-08-24T11:29:10.000000Z 字数 3568 阅读 964

Hadoop 添加/删除datanode节点

大数据


摘自:http://blog.leanote.com/post/moonssang/Hadoop-%E6%B7%BB%E5%8A%A0%E6%96%B0%E8%8A%82%E7%82%B9

/etc/hosts
  1. [hadoop@master hadoop]$ cat /etc/hosts
  2. ## 追加slave
  3. 172.16.1.162 master
  4. 172.16.1.163 slave1
  5. 172.16.1.164 slave2
  6. 172.16.1.165 slave3

配置master免密码登录slave (新节点)
  1. ## 将master节点/home/hadoop/.ssh/id_rsa.pub内容复制到从节点/home/hadoop/.ssh/authorized_keys
  2. ## /home/hadoop/.ssh 为700
  3. [hadoop@dev-164 ~]$ ls -ld .ssh
  4. drwx------ 2 hadoop hadoop 29 Aug 23 15:58 .ssh
  5. ## /home/hadoop/.ssh/authorized_keys 为600
  6. [hadoop@dev-164 ~]$ ls -l .ssh/authorized_keys
  7. -rw------- 1 hadoop hadoop 396 Aug 23 15:58 .ssh/authorized_keys
  8. [hadoop@dev-164 .ssh]$ pwd
  9. /home/hadoop/.ssh
  10. [hadoop@dev-164 .ssh]$ ls
  11. authorized_keys
  12. [hadoop@dev-164 .ssh]$ cat authorized_keys
  13. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIOOEMRSgX3OothfEzneBnoZqfIlD3a5oaDzRmqKDISFx1sXWTBAtKCKRocq4pWU7DKN82hwcskWFlPnxpz2zP42gohPPpz8SuXXMsDsSKbkVpHduaPG9QvKFJRqtPNNnZQ4A5jZ02lZCcvZ3FDzdpyFTecyRejqdS0Q2EfVswQ7Xc/MySrk2/c7DaC/Xrz1oxu/wsHf45vDj0NiXAadufyIGN0SIxJbW50IB3eAKABQuwNU5CQRkTAcJf59xGixarRo4gqtCFAdtdyHoP/RIYgC1dWafA5TIFGbHuwfFEWluJQJPwpQ1w5mIJkRoPgwWVLI2bscghSzEVIGrRBuZZ hadoop@dev-162

其他配置参考

https://www.zybuluo.com/nalan90/note/854642
https://www.zybuluo.com/nalan90/note/860287

  1. ## 注意:
  2. [hadoop@master hadoop]$ cat etc/hadoop/hdfs-site.xml
  3. ## 修改dfs.replication为指定的个数
  4. <configuration>
  5. <property>
  6. <name>dfs.replication</name>
  7. <value>3</value>
  8. </property>
  9. </configuration>

启动新节点并检查
  1. ## 启动新节点,在新节点执行
  2. ./sbin/hadoop-daemon.sh start datanode
  3. (重设datanode数据路径时需要重启datanode)
  4. ./sbin/yarn-daemon.sh start nodemanager
  5. ## 刷新集群节点
  6. [hadoop@master hadoop]$ hdfs dfsadmin -refreshNodes
  7. Refresh nodes successful
  8. ## 查看新的节点信息
  9. [hadoop@master hadoop]$ hdfs dfsadmin -report
  10. Configured Capacity: 160982630400 (149.93 GB)
  11. Present Capacity: 154322644992 (143.72 GB)
  12. DFS Remaining: 154322124800 (143.72 GB)
  13. DFS Used: 520192 (508 KB)
  14. DFS Used%: 0.00%
  15. Under replicated blocks: 0
  16. Blocks with corrupt replicas: 0
  17. Missing blocks: 0
  18. Missing blocks (with replication factor 1): 0
  19. -------------------------------------------------
  20. Live datanodes (3):
  21. Name: 172.16.1.165:50010 (slave3)
  22. Hostname: slave3
  23. Decommission Status : Normal
  24. Name: 172.16.1.163:50010 (slave1)
  25. Hostname: slave1
  26. Decommission Status : Normal
  27. Name: 172.16.1.164:50010 (slave2)
  28. Hostname: slave2
  29. Decommission Status : Normal

WebUI

image_1bo923u706aq17p7mh87r71g8f9.png-99.9kB


卸载节点
  1. ## 修改conf/hdfs-site.xml文件
  2. <property>
  3.   <name>dfs.hosts.exclude</name>
  4.   <value>/usr/local/hadoop/etc/hadoop/dfs-hosts.exclude</value>
  5.   <description>Names a file that contains a list of hosts that are not permitted to connect to the namenode. The full pathname of the file must be specified.If the value is empty, no hosts are excluded.</description>
  6. </property>
  7. ## 将要下架的机器写到dfs-hosts.exclude中
  8. slave4
  9. ## 强制重新加载配置 进入hadoop根目录
  10. bin/hdfs dfsadmin -refreshNodes

WebUI
  1. http://172.16.1.162:50070/dfshealth.html#tab-datanode
  2. ## 正在执行Decommission,会显示:
  3. Decommission Status : Decommission in progress

image_1bo93geeq1f4g18n6n91vbd1j3lm.png-104.1kB


  1. ## 执行完毕后,会显示:
  2. Decommission Status : Decommissioned

image_1bo93hq5i1hqioa69na1jqe1e5513.png-99.4kB


  1. ## 命令行查看节点信息
  2. [hadoop@master hadoop]$ hdfs dfsadmin -refreshNodes
  3. Refresh nodes successful
  4. [hadoop@master hadoop]$ hdfs dfsadmin -report
  5. Configured Capacity: 107321761792 (99.95 GB)
  6. Present Capacity: 102881239040 (95.82 GB)
  7. DFS Remaining: 102880718848 (95.82 GB)
  8. DFS Used: 520192 (508 KB)
  9. DFS Used%: 0.00%
  10. Under replicated blocks: 0
  11. Blocks with corrupt replicas: 0
  12. Missing blocks: 0
  13. Missing blocks (with replication factor 1): 0
  14. -------------------------------------------------
  15. Live datanodes (3):
  16. Name: 172.16.1.165:50010 (slave3)
  17. Hostname: slave3
  18. Decommission Status : Decommissioned ## 节点已下线
  19. Name: 172.16.1.163:50010 (slave1)
  20. Hostname: slave1
  21. Decommission Status : Normal
  22. Name: 172.16.1.164:50010 (slave2)
  23. Hostname: slave2
  24. Decommission Status : Normal
  25. ## 在卸载机器上关闭DataNode进程
  26. sbin/hadoop-daemon.sh stop datanode
  27. ## 删除节点后恢复,如果删除后想重新加入:
  28. 1)删除dfs-hosts.exclude文件中要重新加入的节点
  29. 2hadoop dfsadmin -refreshNodes
  30. 3) 重启新加入的节点datanode 进程
  31. ./sbin/hadoop-daemon.sh start datanode
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注