hftest0001
hftest0002
hftest0003
一、动态添加节点
hftest0001 (master node )
[hadoop@hftest0001 hadoop]$ pwd
/home/hadoop/hadoop-2.7.1/etc/hadoop
[hadoop@hftest0001 hadoop]$ cat masters
hftest0001.webex.com
[hadoop@hftest0001 hadoop]$ cat slaves
hftest0002.webex.com
[hadoop@hftest0001 hadoop]$ cat hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
...
...
<configuration>
hftest0002 (data node)
[hadoop@hftest0002 hadoop]$ pwd
/home/hadoop/hadoop-2.7.1/etc/hadoop
[hadoop@hftest0002 hadoop]$ cat masters
hftest0001.webex.com
[hadoop@hftest0002 hadoop]$ cat slaves
hftest0002.webex.com
[hadoop@hftest0002 hadoop]$ cat hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
...
...
<configuration>
[hadoop@hftest0001 hadoop-2.7.1]$ ./bin/hdfs dfs -ls /tmp
Found 1 items
-rw-r--r-- 1 hadoop supergroup 1366 2016-01-28 13:48 /tmp/README.txt ===> replication 1
准备:
创建新节点hftest0003
修改hostname(/etc/sysconf/network) 和 hosts(/etc/hosts) 使得集群相互ping通
修改slaves文件,添加新节点
修改replication=>2
[hadoop@hftest0001 hadoop]$ pwd
/home/hadoop/hadoop-2.7.1/etc/hadoop
[hadoop@hftest0003 hadoop]$ cat masters
hftest0001.webex.com
[hadoop@hftest0003 hadoop]$ cat slaves
hftest0002.webex.com
hftest0003.webex.com
[hadoop@hftest0003 hadoop]$ cat hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
...
...
<configuration>
注意:所有的集群全部需要修改
[hadoop@hftest0001 hadoop-2.7.1]$ pwd
/home/hadoop/hadoop-2.7.1
启动datanode
[hadoop@hftest0001 hadoop-2.7.1]$ ./sbin/hadoop-daemon.sh start datanode
...
...
webui可以校验
[hadoop@hftest0001 hadoop-2.7.1]$ ./sbin/start-balancer.sh -threshold 5
启动nodemanager
[hadoop@hftest0001 hadoop-2.7.1]$ ./sbin/yarn-daemon.sh start nodemanager
...
...
[hadoop@hftest0001 hadoop-2.7.1]$ ./bin/hdfs dfs -ls /tmp
Found 2 items
-rw-r--r-- 2 hadoop supergroup 101 2016-01-28 13:54 /tmp/NOTICE.txt ====> replication=2
-rw-r--r-- 1 hadoop supergroup 1366 2016-01-28 13:48 /tmp/README.txt
二、删除节点