spark 笔记
?
?
spark采用分布式計算中的master-slave模型,master對應含有master進程的節點,slave對應含有worker進程的節點。Client 負責提交應用,driver負責控制應用的執行。
?
基本組件
- Cluster manager是master節點,控制整個集群
- Worker: 計算節點
- Driver: 運行application 的main函數 并創建 spark context
- Executor: 用于啟動線程池執行任務,每一個application擁有一組獨立的 Executor
- Spark context: 整個應用的上下文,控制應用的生命周期
- RDD DAG: 一組RDD構成的有向無環圖。當RDD遇到一個action算子時候,將之前所有的算子形成一個rdd graph. 并把這個rdd graph轉化為job提交到cluster中執行
- Job. 一個Rdd Graph觸發的作業。往往由Spark Context通過 runJob方法向spark 提交job
- DAG scheduler. 每個job會根據RDD DAG構建 Stage DAG, 并把stage交給 Task Scheduler。
- Task Scheduler: 將task 分發給 task scheduler
- SparkEnv: 線程級別的上下文
Spark Env包括以下幾部分
?
spark主要流程
?
RDD兩種創建方式
?
RDD 相關
Note: 如果是從HDFS等外部存儲結構中讀取數據,數據則按照HDFS中的數據分布策略進行數據分區,HDFS中的一個block對應spark的一個分區?
?
?
Transformation 算子
輸入輸出分區一對一型
輸入和輸出分區多對一
輸入輸出多對多
輸出是輸入分區的子集。
cache型算子
?
Action 算子
?RDD Dependencies
1. Narrow Dependencies. ?each partition of the parent RDD is used by at most one partition of the child RDD.
- allow for pipelined execution on one cluster node.
- easy fault recovery
- Transformation: map、flatMap、filter、sample
2. Wide Dependencies. multiple child partitions may depend on a parent partition.
- require data from all parent partitions to be available and to be shuffled across the nodes
- a single failed node might cause a complete reexecution
- Transformation:?sortByKey、reduceByKey、groupByKey、cogroupByKey、join、cartensian
? ? ? ?
?
?
?
轉載于:https://www.cnblogs.com/shexinwei/p/4614697.html
總結
- 上一篇: 电脑怎么不读取u盘启动 电脑无法通过u盘
- 下一篇: 怎么个性化U盘系统 个性化你的U盘系统,