Hadoop 2.6.3 dynamically add/remove DataNode
假设集群操作系统均为:CentOS 6.7 x64, Hadoop版本为:2.6.3
动态增加DataNode
1、准备新的DataNode节点机器,配置SSH互信,可以直接复制已有DataNode中.ssh目录中的authorized_keys和id_rsa
2、复制Hadoop运行目录、hdfs目录及tmp目录至新的DataNode
3、在新DataNode上启动hadoop
../sbin/hadoop-daemon.sh start datanode
../sbin/yarn-daemon.sh start datanode
4、在NameNode上刷新节点
../bin/hdfs dfsadmin -refreshNodes
../sbin/start-balancer.sh
5、为方便下次启动,可以将新DataNode的域名和ip加入/etc/hosts中
动态删除DataNode
1、配置NameNode的hdfs-site.xml,适当减小dfs.replication副本数,增加dfs.hosts.exclude配置
<property>
<name>dfs.hosts.exclude</name>
<value>/usr/local/hadoop2/etc/hadoop/excludes</value>
</property>
2、在对应路径(/etc/hadoop/)下新建excludes文件,并写入待删除DataNode的ip或域名
3、在NameNode上刷新所有DataNode
../bin/hdfs dfsadmin -refreshNodes
../sbin/start-balancer.sh
4、此时,可以在web检测界面(ip:50070)上可以观测到DataNode逐渐变为Dead。
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here