【甘道夫】Spark1.3.0 Cluster Mode Overview 官方文档精华摘要

引言
由于工作需要,即将拥抱Spark,曾经进行过相关知识的学习,现在计划详细读一遍最新版本Spark1.3的部分官方文档,一是复习,二是了解最新进展,三是为公司团队培训做储备。

欢迎转载,请注明出处:
http://blog.csdn.net/u010967382/article/details/45062323

该文档重点介绍了Spark集群架构中的各个关键组件,对于我们理解Spark的运行原理至关重要。

文档内容主要是在解释下图,及相关术语:


上图的核心概念描述如下:
  1. Spark应用程序以一组独立进程的形式运行在集群中,应用程序的main方法中的SparkContext对象负责调度控制这一组独立进程的合作,这个包含main方法的程序叫Driver Program
  2. Cluster Manager为运行在集群中的应用程序分配资源。SparkContext对象可以连接多种类型的Cluster Manager,包括Spark自带的standalone cluster manager,或者Mesos/YARN
  3. 一旦SparkContext对象成功连接Cluster Manager,Spark应用程序就可以获取到集群中各个节点上的executor,这些executor将为你的应用执行计算任务和存储数据;
  4. 接下来,SparkContext将分发应用程序代码到各个executor上;
  5. 最后,SparkContext将分发tasks到各个executor上去运行。

在这个运行架构中,有一些需要注意的要点:
  • 每个应用程序都有它自己的一组executor进程,这组executor进程在应用的全生命周期内运行,负责以多线程方式运行自己分配到的task。这样做的好处是可以隔离不同的应用程序。然而,这也意味着,数据不能跨应用程序(SparkContext的实例)共享,除非将数据写入一个外部的存储系统(比如Tachyon?)。
  • 因为driver程序负责调度在集群上运行的tasks,所以driver应该贴近worker节点运行,最好在相同的局域网内,否则两者相隔较远的话,driver和worker之间的通信会对程序执行带来影响。

Spark支持三种类型的Cluster Manager:
  • Standalone – Spark自带的相对简单的集群管理器;
  • Apache Mesos – 一个通用的集群管理器,它同时也可以运行Hadoop MR程序和其它服务应用;
  • Hadoop YARN – Hadoop2.0中的资源管理器。

我们可以通过spark-submit脚本提交应用程序到任意一类Cluster Manager上。


Spark应用程序的监控:每一个driver程序都有一个web UI,经典的在4040端口,展示了正在运行的task、executors和存储情况的相关信息。我们可以简单的通过http://<driver-node>:4040在浏览器中进入web UI,如下图:


注意,这里的地址是driver-node,不是master node。


Spark的资源分配控制同时在两个级别进行:

  • 跨应用程序级别(在Cluster Manager级别);
  • 应用程序内部级别(如果多个计算任务同时在一个SparkContext上发生)。


最后是术语表,尤其重要,务必理解熟记

Term Meaning
Application User program built on Spark. Consists of a driver program and executors on the cluster.
Application = 一个driver + 多个executor
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.
应用程序jar文件某些情况下会包含所有的依赖包,但是千万不要包含Hadoop或者Spark的依赖库,这些依赖库在程序运行时会添加。
Driver program The process running the main() function of the application and creating the SparkContext
运行main()方法创建SparkContext实例的进程。
Cluster manager An external service for acquiring resources on the cluster (e.g. standalone manager, Mesos, YARN)
一个外部服务,用于获取集群资源,例如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.
区分driver进程运行在哪里:
  • 在cluster模式中,Spark框架在集群中启动driver进程。
  • 在client模式中,submitter在集群外启动driver进程。
Worker node Any node that can run application code in the cluster
可以运行application代码的集群节点。
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.
为运行application在worker nodes上启动的线程,这些线程负责运行tasks,及保存数据在内存或磁盘。
每一个applicaiton都有自己的一组executor!
Task A unit of work that will be sent to one executor
一个工作单元,将被发送到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.
Spark action(例如save,collect)触发的一系列并行计算tasks。
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.
每一个job将分为很多组task,每一组task称为一个stage,这些stage相互依赖。类似于MapReduce计算模型中的map和reduce stage。

猜你喜欢

转载自blog.csdn.net/u010967382/article/details/45062323