3.Spark 集群模式

Spark 集群模式

系统当前支持几种集群管理器:

  • Standalone – 包含在spark中的一个简单集群管理器,它使得设置一个集群很容易。
  • Apache Mesos – 一个通用集群管理器,也能运行Hadoop MapReduce 和 service 应用。
  • Hadoop YARN – the resource manager in Hadoop 2.
  • Kubernetes – an open-source system for automating deployment, scaling, and management of containerized applications.

A third-party project (not supported by the Spark project) exists to add support for Nomad as a cluster manager.

Cluster Mode Overview

This document gives a short overview of how Spark runs on clusters, to make it easier to understand the components involved. Read through the application submission guide to learn about launching applications on a cluster.

Components

Spark applications run as independent sets of processes on a cluster, coordinated by the SparkContext object in your main program (called the driver program).

Specifically, to run on a cluster, the SparkContext can connect to several types of cluster managers (either Spark’s own standalone cluster manager, Mesos or YARN), which allocate resources across applications. Once connected, Spark acquires executors on nodes in the cluster, which are processes that run computations and store data for your application. Next, it sends your application code (defined by JAR or Python files passed to SparkContext) to the executors. Finally, SparkContext sends tasks to the executors to run.

There are several useful things to note about this architecture:

  1. Each application gets its own executor processes, which stay up for the duration of the whole application and run tasks in multiple threads. This has the benefit of isolating applications from each other, on both the scheduling side (each driver schedules its own tasks) and executor side (tasks from different applications run in different JVMs). However, it also means that data cannot be shared across different Spark applications (instances of SparkContext) without writing it to an external storage system.
  2. Spark is agnostic to the underlying cluster manager. As long as it can acquire executor processes, and these communicate with each other, it is relatively easy to run it even on a cluster manager that also supports other applications (e.g. Mesos/YARN).
  3. The driver program must listen for and accept incoming connections from its executors throughout its lifetime (e.g., see spark.driver.port in the network config section). As such, the driver program must be network addressable from the worker nodes.
  4. Because the driver schedules tasks on the cluster, it should be run close to the worker nodes, preferably on the same local area network. If you’d like to send requests to the cluster remotely, it’s better to open an RPC to the driver and have it submit operations from nearby than to run a driver far away from the worker nodes.

Cluster Manager Types

The system currently supports several cluster managers:

  • Standalone – a simple cluster manager included with Spark that makes it easy to set up a cluster.
  • Apache Mesos – a general cluster manager that can also run Hadoop MapReduce and service applications.
  • Hadoop YARN – the resource manager in Hadoop 2.
  • Kubernetes – an open-source system for automating deployment, scaling, and management of containerized applications.

A third-party project (not supported by the Spark project) exists to add support for Nomad as a cluster manager.

Submitting Applications

Applications can be submitted to a cluster of any type using the spark-submit script. The application submission guide describes how to do this.

Monitoring

Each driver program has a web UI, typically on port 4040, that displays information about running tasks, executors, and storage usage. Simply go to http://<driver-node>:4040 in a web browser to access this UI. The monitoring guide also describes other monitoring options.

Job Scheduling

Spark gives control over resource allocation both across applications (at the level of the cluster manager) and within applications (if multiple computations are happening on the same SparkContext). The job scheduling overview describes this in more detail.

Glossary

The following table summarizes terms you’ll see used to refer to cluster concepts:

Term Meaning
Application User program built on Spark. Consists of a driver program and executors on the cluster.
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 process 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.

原文地址:https://www.cnblogs.com/springwind2020/p/12344956.html

时间: 2024-08-29 17:01:41

3.Spark 集群模式的相关文章

Spark集群模式&amp;Spark程序提交

Spark集群模式&Spark程序提交 1. 集群管理器 Spark当前支持三种集群管理方式 Standalone-Spark自带的一种集群管理方式,易于构建集群. Apache Mesos-通用的集群管理,可以在其上运行Hadoop MapReduce和一些服务应用. Hadoop YARN-Hadoop2中的资源管理器. Tip1: 在集群不是特别大,并且没有mapReduce和Spark同时运行的需求的情况下,用Standalone模式效率最高. Tip2: Spark可以在应用间(通过集

【待补充】Spark 集群模式 &amp;&amp; Spark Job 部署模式

0. 说明 Spark 集群模式 && Spark Job 部署模式 1. Spark 集群模式 [ Local ] 使用一个 JVM 模拟 Spark 集群 [ Standalone ] 启动 master + worker 进程 [ mesos ] -- [ Yarn ] -- 2. Spark Job 部署模式 [ Client ] Driver 程序运行在 Client 端. [ Cluster ] Driver 程序运行在某个 worker 上. spark-shell 只能以

【Spark01】SparkSubmit兼谈Spark集群管理和部署模式

关于Cluster Manager和Deploy Mode的组合在SparkSubmit.scala的createLaunchEnv中有比较详细的逻辑. Cluster Manager基本上有Standalone,YARN和Mesos三种情况,说明Cluster Manager用来指明集群的资源管理器.这就是说不管是Client还是Cluster部署方式(deployMode的两种可能),都会使用它们做集 群管理器,也就是说Client也是一种集群部署方式??? /** * @return a

Apache Spark 2.2.0 中文文档 - 集群模式概述 | ApacheCN

集群模式概述 该文档给出了 Spark 如何在集群上运行.使之更容易来理解所涉及到的组件的简短概述.通过阅读 应用提交指南 来学习关于在集群上启动应用. 组件 Spark 应用在集群上作为独立的进程组来运行,在您的 main 程序中通过 SparkContext 来协调(称之为 driver 程序). 具体的说,为了运行在集群上,SparkContext 可以连接至几种类型的 Cluster Manager(既可以用 Spark 自己的 Standlone Cluster Manager,或者

Spark教程-构建Spark集群-配置Hadoop单机模式并运行Wordcount(1)

安装ssh Hadoop是采用ssh进行通信的,此时我们要设置密码为空,即不需要密码登陆,这样免去每次通信时都输入秘密,安装如下: 输入“Y”进行安装并等待自动安装完成. 安装ssh完成后启动服务 以下命令验证服务是否正常启动: 可以看到ssh正常启动: 设置免密码登录,生成私钥和公钥: 在/root/.ssh中生成两个文件:id_rsa和id_rsa.pub,id_rsa为私钥,id_rsa.pub为公钥,我们将公钥id_rsa.pub追加到 authorized_keys中,因为author

Spark新手入门——3.Spark集群(standalone模式)安装

主要包括以下三部分,本文为第三部分: 一. Scala环境准备 查看二. Hadoop集群(伪分布模式)安装 查看三. Spark集群(standalone模式)安装 Spark集群(standalone模式)安装 若使用spark对本地文件进行测试学习,可以不用安装上面的hadoop环境,若要结合hdfs使用spark,则可以参考上面的步骤搭建hadoop. 1. 下载安装包并解压(如:~/tools/spark-2.3.1-bin-hadoop2.7): 2. 启动服务 a.启动master

Spark集群-Standalone 模式

Spark 集群相关 来源于官方, 可以理解为是官方译文, 外加一点自己的理解. 版本是2.4.4 本篇文章涉及到: 集群概述 master, worker, driver, executor的理解 打包提交,发布 Spark application standalone模式 SparkCluster 启动 及相关配置 资源, executor分配 开放网络端口 高可用(Zookeeper) 名词解释 Term(术语) Meaning(含义) Application 用户构建在 Spark 上的

Spark API编程动手实战-02-以集群模式进行Spark API实战textFile、cache、count

操作HDFS:先要保证HDFS启动了: 启动spark集群: 以spark-shell运行在spark集群上: 查看下之前上传到HDFS上的"LICENSE.txt"文件: 用spark读取这个文件: 使用count统计该文件的行数: 我们可以看到count 耗时为0.239708s 对该RDD进行cache操作并执行count使得缓存生效: 执行count结果为: 此时耗时为0.21132s 再执行count操作: 此时耗时为0.029580s,这时因为我们自己基于cache后的数据

Spark API编程动手实战-02-以集群模式进行Spark API实战textFile、cach

操作HDFS:先要保证HDFS启动了: 启动spark集群: 以spark-shell运行在spark集群上: 查看下之前上传到HDFS上的"LICENSE.txt"文件: 用spark读取这个文件: 使用count统计该文件的行数: 我们可以看到count 耗时为0.239708s 对该RDD进行cache操作并执行count使得缓存生效: 执行count结果为: 此时耗时为0.21132s 再执行count操作: 此时耗时为0.029580s,这时因为我们自己基于cache后的数据