添加節點
1.修改host
和普通的datanode一樣。添加namenode的ip
和普通的datanode一樣。添加namenode的ip
2.修改namenode的配置文件conf/slaves
添加新增節點的ip或host
3.在新節點的機器上,啟動服務
[root@slave-004 Hadoop]# ./bin/hadoop-daemon.sh start datanode[root@slave-004 hadoop]# ./bin/hadoop-daemon.sh start tasktracker
4.均衡block
[root@slave-004 hadoop]# ./bin/start-balancer.sh
1)如果不balance,那么cluster會把新的數據都存放在新的node上,這樣會降低mapred的工作效率
2)設置平衡閾值,默認是10%,值越低各節點越平衡,但消耗時間也更長
[root@slave-004 hadoop]# ./bin/start-balancer.sh -threshold 5
3)設置balance的帶寬,默認只有1M/s
<property> <name>dfs.balance.bandwidthPerSec</name> <value>1048576</value> <description> Specifies the maximum amount of bandwidth that each datanode can utilize for the balancing purpose in term of the number of bytes per second. </description> </property>
注意:
1. 必須確保slave的firewall已關閉;
2. 確保新的slave的ip已經添加到master及其他slaves的/etc/hosts中,反之也要將master及其他slave的ip添加到新的slave的/etc/hosts中
1. 必須確保slave的firewall已關閉;
2. 確保新的slave的ip已經添加到master及其他slaves的/etc/hosts中,反之也要將master及其他slave的ip添加到新的slave的/etc/hosts中
刪除節點
1.集群配置
修改conf/hdfs-site.xml文件
修改conf/hdfs-site.xml文件
<property> <name>dfs.hosts.exclude</name> <value>/data/soft/hadoop/conf/excludes</value> <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> </property>
2確定要下架的機器
dfs.hosts.exclude定義的文件內容為,每個需要下線的機器,一行一個。這個將阻止他們去連接Namenode。如:
slave-003 slave-004
3.強制重新加載配置
[root@master hadoop]# ./bin/hadoop dfsadmin -refreshNodes
它會在后台進行Block塊的移動
4.關閉節點
等待剛剛的操作結束后,需要下架的機器就可以安全的關閉了。
[root@master hadoop]# ./bin/ hadoop dfsadmin -report
可以查看到現在集群上連接的節點
正在執行Decommission,會顯示: Decommission Status : Decommission in progress 執行完畢后,會顯示: Decommission Status : Decommissioned
5.再次編輯excludes文件
一旦完成了機器下架,它們就可以從excludes文件移除了
登錄要下架的機器,會發現DataNode進程沒有了,但是TaskTracker依然存在,需要手工處理一下
http://www.dataguru.cn/forum.php?mod=viewthread&tid=175348