一、如何添加節點?
大概配置思路:(轉載於https://blog.csdn.net/czz1141979570/article/details/86712881)
1、在新節點中進行操作系統的配置,包括主機名配置,防火牆,網絡,免密登陸和安裝JDK等
2、在所有的節點的/etc/hosts文件中增加新節點
3、把namenode的有關配置文件複製到該節點
4、修改master節點的slaves文件,增加該節點
5、單獨啓動該節點上的datanode和NodeManager
./sbin/hadoop-daemon.sh start datanode
./sbin/yarn-daemon.sh start nodemanager
6、運行start-balancer.sh進行數據負載均衡操作
(負載均衡詳細介紹可參考https://www.ibm.com/developerworks/cn/data/library/bd-1506-hdfsdatabalance/index.html)
./bin/start-balancer.sh
1)如果不balance,那麼cluster會把新的數據都存放在新的node上,這樣會降低mapred的工作效率
2)設置平衡閾值,默認是10%,值越低各節點越平衡,但消耗時間也更長
./bin/start-balancer.sh -threshold 5
3)設置balance的帶寬,默認只有1M/s
(也可通過命令設置:hdfs dfsadmin -setBalancerBandwidth 20971520)
<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>
具體操作請參考:https://www.cnblogs.com/skyl/p/4854654.html
二、如何刪除節點?
第一次刪除節點,直接刪掉HADOOP節點,之後纔想起來hbase也要移除,先移除hadoop再移除hbase,導致出現Hmaster啓動失敗,META表找不到問題(org.apache.hadoop.hbase.NotServingRegionException: org.apache.hadoop. hbase. NotServingRegionException:hbase:meta,,1 is not online on nn0-eth0,16020),找了好久沒找到解決方案,最後猜測應該是hbase找不到之前存在hdfs裏面的region信息。最後將集羣節點恢復才解決問題。
因此,刪除節點不能馬虎,稍不留神以前的數據就GG了,經過對比網友的解決方案,最終選用如下方案執行:
移除順序是,先移除hbase的regionserver等服務,再移除hadoop的DataNode。而新增的順序相反,先新增datanode,再新增regionserver。
具體實現方案如下:
對於HBASE:
此鏈接比較詳細:http://shitouer.cn/2013/03/hadoop-or-hbase-cluster-remove-nodes/
具體執行比較簡單,直接在Master上執行./bin/graceful_stop.sh hostname命令即可,最後在hbase shell中執行負載均衡:
balance_switch true。
對於Hadoop:
1.集羣配置,設置excludes路徑
修改 Namenode上etc/hadoop/hdfs-site.xml文件
<property>
<name>dfs.hosts.exclude</name>
<value>/hadoop2.7.2/etc/hadoop/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.確定要刪除的節點
在第一步指定的路徑下,新建excludes文件,將需要移除的主機名寫入,一行一個。
3.強制重新加載配置
[ws@master hadoop]# ./bin/hadoop dfsadmin -refreshNodes
4.查看執行狀態
可通過在hadoop網頁(http://NameNodes:50070)上查看datanode狀態,也可以通過如下命令查看:
[ws@master hadoop]# ./bin/hadoop dfsadmin -report
正在執行Decommission,會顯示:Decommission Status : Decommission in progress
執行完畢後,會顯示:Decommission Status : Decommissioned
5.備註
等狀態變成Decommissioned後就可以關閉這個節點了,可在要移除的節點上運行相應的關閉命令,如:./hadoop-daemon.sh stop datanode,幾分鐘後,節點將從Decommissioned進入Dead狀態。
登錄該節點,若還有其他進程,可手動關閉。
一旦完成了機器移除,它們就可以從excludes文件移除了。
記得從NameNode的excludes文件及slaves文件中去掉已經移除的主機名。
要移除的節點上的數據不會被刪除,如果數據比較敏感,要手動刪除它們。
6.重新加入刪除的節點
1).在master的excludes文件中刪除相應節點IP
2).在slave上重啓datanode和nodemanager進程:hadoop-daemon.sh start datanode yarn-damon.sh start nodemanager
3).在master上刷新節點配置情況:hadoop dfsadmin -refreshNodes