HDFS
A. ha dfs 初始化和啟動
- 啟動zookeeper集群
- 在主Name結點上 格式化zookeeper上相應目錄
hdfs zkfc -formatZK
- 格式化主NameNode, 格式化會格式化已存在的結點元數據
hdfs namenode -format
- 啟動Journal Node集群
hadoop-daemon.sh start journalnode
- 啟動主結點NameNode
hadoop-daemon.sh start namenode
- 格式化備NameNode
hdfs namenode -bootstrapStandby
- 啟動備結點NameNode
hadoop-daemon.sh start namenode
- 兩個NameNode上啟動 zkfc
hadoop-daemon.sh start zkfc
- 啟動所有結點的datanode
hadoop-daemon.sh start datanode
B. Balancer
在線上的hadoop集群運維過程中,hadoop 的balance工具通常用于平衡hadoop集群中各datanode中的文件塊分布,以避免出現部分datanode磁盤占用率高的問題(這問題也很有可能導致該節點CPU使用率較其他服務器高)
The tool moves blocks from highly utilized datanodes to poorly utilized datanodes
iteratively. In each iteration a datanode moves or receives no more than the lesser of 10G
bytes or the threshold fraction of its capacity. Each iteration runs no more than 20
minutes. At the end of each iteration, the balancer obtains updated datanodes information
from the namenode.
描述
-threshold 默認設置:10,參數取值范圍:0-100,參數含義:判斷集群是否平衡的目標參數,每一個 datanode 存儲使用率和集群總存儲使用率的差值都應該小于這個閥值 ,理論上,該參數設置的越小,整個集群就越平衡,但是在線上環境中,hadoop集群在進行balance時,還在并發的進行數據的寫入和刪除,所以有可能無法到達設定的平衡參數值。
dfs.balance.bandwidthPerSec 默認設置:1048576(1 M/S),參數含義:設置balance工具在運行中所能占用的帶寬,設置的過大可能會造成mapred運行緩慢腳本
hdfs balancer -threshold 5
或
start-balancer.sh
start-balancer.sh [-threshold <threshold>] # 啟動 balancer
hdfs dfsadmin -setBalancerBandwidth <bandwidth in bytes per second> # adjust the network bandwidth used by the balancer
-
什么是balance
rebalance的目的是為了使數據在集群中各節點的分布盡量均衡,那么,什么樣的情況被認為是不均衡,又需要達到什么樣的目標才算是完成了rebalance呢?簡單來說,如果集群中沒有“過載”或者“負載”的節點,則認為集群中的數據分布是均衡的,否則就是不均衡。所謂的“過載節點”是指存儲使用率大于“平均存儲使用率+允許偏差”的節點,“負載節點”是指存儲使用率小于“平均存儲使用率-允許偏差”的節點。這里又出現了幾個概念,下面一一解釋。 什么是一個節點的存儲使用率?它表示一個數據節點上已用空間占可用空間的百分比,所謂可用空間指的是分配給HDFS可使用的空間,并非是節點所在機器的全部硬盤空間。比如,一個數據節點,共有存儲空間2T,分配給HDFS的空間為1T,已經用了600G,那么使用率就是600/1000=60%。 將集群中各節點的存儲使用率做個簡單平均,就得到集群中節點的平均存儲使用率。舉例來說,假設有三個節點A,B,C,HDFS容量分別為2T,2T,1T,分別使用了50%,50%,10%,那么平均使用率是(50%+50%+10%)/3=36.7%,而不是(2*50%+2*50%+1*10%)/(2+2+1)=42%。 允許偏差,是啟動Rebalance功能的時候指定的一個閾值,也是一個百分比,如果沒有指定則默認為是10%,表示允許單個節點的存儲使用率與集群中各節點平均存儲使用率之間有10%的偏差。 Rebalance過程可以指定多次,每次可以指定不同的允許偏差值,以此來逐次漸進達到一個合理的數據均衡分布,同時又不至于使得Rebalance過程持續時間過長,影響集群的正常使用。
C. Decommission & Recommission
- Decommision
- 配置 (在NameNode機器上)
<property>
<name>dfs.hosts.exclude</name>
<value>/home/hadoop/env/conf/exclude-hosts</value>
</property>
或者 使用默認的 <HADOOP_CONF_DIR>/dfs.exclude 文件
2. 在NameNode機器上, exclude-hosts中寫入需要decommission的結點
> On the NameNode host machine, edit the <HADOOP_CONF_DIR>/dfs.exclude
file and add the list of DataNodes hostnames (separated by a newline character).
3. 執行
> Update the NameNode with the new set of excluded DataNodes. On the NameNode host machine, execute the following command:
su <HDFS_USER>
hdfs dfsadmin -refreshNodes
4. 在NameNode Web UI中check **Decommission In Progress** 。當結點狀態都變成 **Decommissioned**,就可以shut down這些結點
5. 如果集群配置了 dfs.include file 或者 在slaves文件中,把Decommissioned結點從其中刪除,然后執行:
su <HDFS_USER>
hdfs dfsadmin -refreshNodes
Yarn
A. Web UI 任務時間
默認情況,顯示的是UTC時間
- 修改:
查看 hadoop-2.6.3/share/hadoop/yarn/hadoop-yarn-common-2.6.3.jar!/webapps/static/yarn.dt.plugins.js
腳本里面的 renderHadoopDate方法,修改Date格式化輸出的方法。
- return new Date(parseInt(data)).toUTCString();
+ return new Date(parseInt(data)).toString();
修改后,重啟yarn.
B. 更改yarn fair schedule queue
- 修改fair-scheduler.xml
- yarn rmadim -refreshQueues
C. 資源隊列使用
- 配置
- TEZ (tez-site.xml)
<property>
<name>tez.queue.name</name>
<value>operations</value>
</property>
- MR (mapred-site.xml)
<property>
<name>mapred.job.queue.name</name>
<value>operations</value>
</property>
D. Decommission
- 配置:
yarn.resourcemanager.nodes.exclude-path (yarn-site.xml)
或者
<HADOOP_CONF_DIR>/yarn.exclude
增加需要退伍的結點
如果配置了 `<HADOOP_CONF_DIR>/yarn.include`, 把對應結點刪除
- 執行:
su <YARN_USER>
yarn rmadmin -refreshNodes
E. 修改yarn資源配置
- yarn.scheduler.maximum-allocation-mb:
<property>
<name>yarn.scheduler.maximum-allocation-mb</name>
<value>10240</value>
</property>
修改后重啟yarn
持續更新中……