Apache hadoop introduction
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
hadoop 介紹影片
https://www.youtube.com/watch?v=4DgTLaFNQq0
hadoop 是一個 base on 分散式系統的大型資料儲存系統,由一到多個 cluster 所組成,由一到多台的 server 所組成,而資料在 cluster 中採取 HDFS 分散式檔案系統 (Hadoop Distributed File System),在資料處理使用 MapReduce 平行運算架構加速處理巨量數據的速度。
HDFS (Hadoop Distributed File System)
HDFS 運作方式為,Cluster 中有數千萬的節點,每個 cluster 中會有一個 Master Node 和多個 Worker Node , Master Node 在存放數據時會將一份資料切格為數塊 (block),每個 block 的大小為 64MB,再將數據複製 (Data Replication) 三份,三份都交由 Worker Node 分別保管,而 Worker Node 會透過 Datanode 儲存數據,並且 Master Node 會透過 Namenode 統一監控所有數據,當 Namenode 發現在某個 Worker Node 上有數據遺失,則會尋找 DataNode 上的副本 (Replica) 並在保持數據在系統上都擁有三份的狀態。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
MapReduce 平行運算架構
前面提到 HDFS 運作下會將資料儲存在數台機器裡,在機器進行資料分析處理時,會使用 MapReduce 也就是平行運算架構,將資料分散丟進數個節點 (Mapping) ,透過多個節點同時平行運算,再將傳送回來的數據進行整合 (Reducing),在處理巨量數據時可以大大節省時間。
模型流程
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- fork: 將要執行的 MapReduce 程式複製到 Master Node 與每一個 Worker Node 中。
- assign map: Master Node 會決定 Map 程式與 Reduce 程式在那些 Worker Node 上去運行。
- read: 被分配到進行 map 程式的 Worker Node 首先會根據 Master Node 分配的 link 去 HDFS 系統上讀取檔案,
- local write: 將 Map 後的結果存入 Worker 機器的本地磁碟。
- remote read: 被分配到進行 Reduce 程式的 Worker Node 經過遠端讀取每一份 Map 結果,進行彙整與排序,同時執行 Reduce 程式。
- write: 將使用者需要的運算結果輸出
由於 MapReduce 所有運算的過程都會讀寫檔案,運算效能相較之下就比較慢。運算的功能慢慢的被 Apache Spark 所取代。
Yarn
是一個資源管理系統,用來管理分散式運算使用的資源。在 hadoop 上執行 MapReduce 的運算時會透過 Yarn 管理工作。由一個 ResourceManager 和多個 NodeManager 所組成,預設數量會與 DataNode 相同,主要包含三大模組:ResourceManager(RM)、NodeManager(NM)、ApplicationMaster(AM)。
ResourceManager(RM)
負責整個 cluster 資源管理以及分配,ResourceManager 主要完成的功能包括:
- 與客戶端溝通,處理來自客戶提交的應用
- YARN Scheduler 根據 ApplicationMaster 的請求為其分配資源,不負責 application job 的監控、追蹤、執行狀態反饋、啟動等工作。
NodeManager(NM)
負責完成來自監控並管理工作任務,並且定時向 ResourceManager,是協調者的角色,其工作項目包括:
- NodeManager 是每個節點上的資源和工作管理員,它是管理這臺機器的代理,負責該節點程式的執行,以及該節點資源的管理和監控。YARN 叢集每個節點都執行一個 NodeManager。
- 定時向 ResourceManager 彙報本節點上的資源使用情況和各個 Container 的運行狀態,當 ResourceManager 當機時 NodeManager 自動連線 RM 備用節點。
- 管理 Container 的生命週期,接收並處理 ApplicationMaster 對 container 的啟動、停止等各種請求
ApplicationMaster(AM)
負責每一個 application 的調度和協調:
- 與 ResourceManager 調度器協商以獲取資源,並將得到的資源進一步分配給內部的任務
- 與 NodeManager 溝通以啟動或停止任務
- 監控所有任務的運行狀態,並在任務運行失敗時負責進行容錯處理
Yarn Architecture
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
YARN 的具體工作流程為:
- client 提交 application
- RM 為該應用分配 Container 與對應 NM 通信,要求 NM 在Container 中啟動 AM
- AM 啟動後向 RM 註冊並申請領用 Container 資源
- AM 申請到資源後與 NM 通信,要求啟動任務
- 運行中的程序會向 AM 通過協議通信同步運行狀態與進度
- 在應用執行期間,client 與 AM 通信同步任務狀態訊息
- 應用運行結束後,AM 向 RM 註銷並關閉自己, Container 資源釋放
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
參考
Thank you!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
You can find me on