Spark快速入門系列(3) | 簡單一文了解Spark核心概念

  大家好,我是不溫卜火,是一名計算機學院大數據專業大二的學生,暱稱來源於成語—不溫不火,本意是希望自己性情溫和。作爲一名互聯網行業的小白,博主寫博客一方面是爲了記錄自己的學習過程,另一方面是總結自己所犯的錯誤希望能夠幫助到很多和自己一樣處於起步階段的萌新。但由於水平有限,博客中難免會有一些錯誤出現,有紕漏之處懇請各位大佬不吝賜教!暫時只有csdn這一個平臺,博客主頁:https://buwenbuhuo.blog.csdn.net/

  此篇爲大家帶來的是簡單一文了解Spark核心概念。
1


2

一. 站在集羣角度

1.1 Master

Spark 特有資源調度系統的 Leader。掌管着整個集羣的資源信息,類似於 Yarn 框架中的 ResourceManager,主要功能:

  1. 監聽 Worker,看 Worker 是否正常工作;
  2. Master 對 Worker、Application 等的管理(接收 Worker 的註冊並管理所有的Worker,接收 Client 提交的 Application,調度等待的 Application 並向Worker 提交)。

1.2 Worker

Spark 特有資源調度系統的 Slave,有多個。每個 Slave 掌管着所在節點的資源信息,類似於 Yarn 框架中的 NodeManager,主要功能:

  1. 通過 RegisterWorker 註冊到 Master;
  2. 定時發送心跳給 Master;
  3. 根據 Master 發送的 Application 配置進程環境,並啓動 ExecutorBackend(執行 Task 所需的臨時進程)

二. 站在應用程序角度

2.1 driver program(驅動程序)

  每個 Spark 應用程序都包含一個驅動程序, 驅動程序負責把並行操作發佈到集羣上.
  驅動程序包含 Spark 應用程序中的主函數, 定義了分佈式數據集以應用在集羣中.
  在前面的wordcount案例集中, spark-shell 就是我們的驅動程序, 所以我們可以在其中鍵入我們任何想要的操作, 然後由他負責發佈.
  驅動程序通過SparkContext對象來訪問 Spark, SparkContext對象相當於一個到 Spark 集羣的連接.
  在 spark-shell 中, 會自動創建一個SparkContext對象, 並把這個對象命名爲sc.

3

2.2 executor(執行器)

  SparkContext對象一旦成功連接到集羣管理器, 就可以獲取到集羣中每個節點上的執行器(executor).
  執行器是一個進程(進程名: ExecutorBackend, 運行在 Worker 節點上), 用來執行計算和爲應用程序存儲數據.
  然後, Spark 會發送應用程序代碼(比如:jar包)到每個執行器. 最後, SparkContext對象發送任務到執行器開始執行程序.
4

2.3 RDDs(Resilient Distributed Dataset) 彈性分佈式數據集

  一旦擁有了SparkContext對象, 就可以使用它來創建 RDD 了. 在前面的例子中, 我們調用sc.textFile(…)來創建了一個 RDD, 表示文件中的每一行文本. 我們可以對這些文本行運行各種各樣的操作.

2.4 cluster managers(集羣管理器)

  爲了在一個 Spark 集羣上運行計算, SparkContext對象可以連接到幾種集羣管理器(Spark’s own standalone cluster manager, Mesos or YARN).
  集羣管理器負責跨應用程序分配資源.

三. 專業術語列表

Term Meaning
Application User program built on Spark. Consists of a driver program and executors on the cluster. (構建於 Spark 之上的應用程序. 包含驅動程序和運行在集羣上的執行器)
Application jar A jar containing the user’s Spark application. In some cases users will want to create an “uber jar” containing their application along with its dependencies. The user’s jar should never include Hadoop or Spark libraries, however, these will be added at runtime.
Driver program The thread running the main() function of the application and creating the SparkContext
Cluster manager An external service for acquiring resources on the cluster (e.g. standalone manager, Mesos, YARN)
Deploy mode Distinguishes where the driver process runs. In “cluster” mode, the framework launches the driver inside of the cluster. In “client” mode, the submitter launches the driver outside of the cluster.
Worker node Any node that can run application code in the cluster
Executor A process launched for an application on a worker node, that runs tasks and keeps data in memory or disk storage across them. Each application has its own executors.
Task A unit of work that will be sent to one executor
Job A parallel computation consisting of multiple tasks that gets spawned in response to a Spark action (e.g. save, collect); you’ll see this term used in the driver’s logs.
Stage Each job gets divided into smaller sets of tasks called stages that depend on each other (similar to the map and reduce stages in MapReduce); you’ll see this term used in the driver’s logs.

  本次的分享就到這裏了,


11

  好書不厭讀百回,熟讀課思子自知。而我想要成爲全場最靚的仔,就必須堅持通過學習來獲取更多知識,用知識改變命運,用博客見證成長,用行動證明我在努力。
  如果我的博客對你有幫助、如果你喜歡我的博客內容,請“點贊” “評論”“收藏”一鍵三連哦!聽說點讚的人運氣不會太差,每一天都會元氣滿滿呦!如果實在要白嫖的話,那祝你開心每一天,歡迎常來我博客看看。
  碼字不易,大家的支持就是我堅持下去的動力。點贊後不要忘了關注我哦!

13
12

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章