Skip to content
Snippets Groups Projects
  • Kalvin Chau's avatar
    c8fc1f3b
    [SPARK-20085][MESOS] Configurable mesos labels for executors · c8fc1f3b
    Kalvin Chau authored
    ## What changes were proposed in this pull request?
    
    Add spark.mesos.task.labels configuration option to add mesos key:value labels to the executor.
    
     "k1:v1,k2:v2" as the format, colons separating key-value and commas to list out more than one.
    
    Discussion of labels with mgummelt at #17404
    
    ## How was this patch tested?
    
    Added unit tests to verify labels were added correctly, with incorrect labels being ignored and added a test to test the name of the executor.
    
    Tested with: `./build/sbt -Pmesos mesos/test`
    
    Please review http://spark.apache.org/contributing.html before opening a pull request.
    
    Author: Kalvin Chau <kalvin.chau@viasat.com>
    
    Closes #17413 from kalvinnchau/mesos-labels.
    c8fc1f3b
    History
    [SPARK-20085][MESOS] Configurable mesos labels for executors
    Kalvin Chau authored
    ## What changes were proposed in this pull request?
    
    Add spark.mesos.task.labels configuration option to add mesos key:value labels to the executor.
    
     "k1:v1,k2:v2" as the format, colons separating key-value and commas to list out more than one.
    
    Discussion of labels with mgummelt at #17404
    
    ## How was this patch tested?
    
    Added unit tests to verify labels were added correctly, with incorrect labels being ignored and added a test to test the name of the executor.
    
    Tested with: `./build/sbt -Pmesos mesos/test`
    
    Please review http://spark.apache.org/contributing.html before opening a pull request.
    
    Author: Kalvin Chau <kalvin.chau@viasat.com>
    
    Closes #17413 from kalvinnchau/mesos-labels.
running-on-mesos.md 23.44 KiB
layout: global
title: Running Spark on Mesos
  • This will become a table of contents (this text will be scraped). {:toc}

Spark can run on hardware clusters managed by Apache Mesos.

The advantages of deploying Spark with Mesos include:

  • dynamic partitioning between Spark and other frameworks
  • scalable partitioning between multiple instances of Spark

How it Works

In a standalone cluster deployment, the cluster manager in the below diagram is a Spark master instance. When using Mesos, the Mesos master replaces the Spark master as the cluster manager.

Spark cluster components

Now when a driver creates a job and starts issuing tasks for scheduling, Mesos determines what machines handle what tasks. Because it takes into account other frameworks when scheduling these many short-lived tasks, multiple frameworks can coexist on the same cluster without resorting to a static partitioning of resources.

To get started, follow the steps below to install Mesos and deploy Spark jobs via Mesos.

Installing Mesos

Spark {{site.SPARK_VERSION}} is designed for use with Mesos {{site.MESOS_VERSION}} or newer and does not require any special patches of Mesos.

If you already have a Mesos cluster running, you can skip this Mesos installation step.

Otherwise, installing Mesos for Spark is no different than installing Mesos for use by other frameworks. You can install Mesos either from source or using prebuilt packages.

From Source

To install Apache Mesos from source, follow these steps:

  1. Download a Mesos release from a mirror
  2. Follow the Mesos Getting Started page for compiling and installing Mesos

Note: If you want to run Mesos without installing it into the default paths on your system (e.g., if you lack administrative privileges to install it), pass the --prefix option to configure to tell it where to install. For example, pass --prefix=/home/me/mesos. By default the prefix is /usr/local.

Third-Party Packages

The Apache Mesos project only publishes source releases, not binary packages. But other third party projects publish binary releases that may be helpful in setting Mesos up.

One of those is Mesosphere. To install Mesos using the binary releases provided by Mesosphere:

  1. Download Mesos installation package from downloads page
  2. Follow their instructions for installation and configuration

The Mesosphere installation documents suggest setting up ZooKeeper to handle Mesos master failover, but Mesos can be run without ZooKeeper using a single master as well.

Verification

To verify that the Mesos cluster is ready for Spark, navigate to the Mesos master webui at port :5050 Confirm that all expected machines are present in the slaves tab.

Connecting Spark to Mesos

To use Mesos from Spark, you need a Spark binary package available in a place accessible by Mesos, and a Spark driver program configured to connect to Mesos.

Alternatively, you can also install Spark in the same location in all the Mesos slaves, and configure spark.mesos.executor.home (defaults to SPARK_HOME) to point to that location.

Uploading Spark Package

When Mesos runs a task on a Mesos slave for the first time, that slave must have a Spark binary package for running the Spark Mesos executor backend. The Spark package can be hosted at any Hadoop-accessible URI, including HTTP via http://, Amazon Simple Storage Service via s3n://, or HDFS via hdfs://.