diff options
Diffstat (limited to 'docs')
-rwxr-xr-x | docs/_layouts/global.html | 2 | ||||
-rw-r--r-- | docs/configuration.md | 8 | ||||
-rw-r--r-- | docs/ec2-scripts.md | 13 | ||||
-rw-r--r-- | docs/index.md | 4 | ||||
-rw-r--r-- | docs/running-on-mesos.md | 36 | ||||
-rw-r--r-- | docs/running-on-yarn.md | 16 | ||||
-rw-r--r-- | docs/scala-programming-guide.md | 2 | ||||
-rw-r--r-- | docs/spark-standalone.md | 194 |
8 files changed, 185 insertions, 90 deletions
diff --git a/docs/_layouts/global.html b/docs/_layouts/global.html index 9c84edd840..5aeed99a54 100755 --- a/docs/_layouts/global.html +++ b/docs/_layouts/global.html @@ -63,7 +63,7 @@ <a href="{{HOME_PATH}}api.html" class="dropdown-toggle" data-toggle="dropdown">More<b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="configuration.html">Configuration</a></li> - <li><a href="tuning.html">Tuning</a></li> + <li><a href="tuning.html">Tuning Guide</a></li> <li><a href="bagel-programming-guide.html">Bagel (Pregel on Spark)</a></li> <li><a href="contributing-to-spark.html">Contributing to Spark</a></li> </ul> diff --git a/docs/configuration.md b/docs/configuration.md index 93a644910c..0b6be26bba 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -80,9 +80,9 @@ there are at least four properties that you will commonly want to control: <td>spark.cores.max</td> <td>(infinite)</td> <td> - When running on a <a href="{{BASE_PATH}}spark-standalone.html">standalone deploy cluster</a> or a - <a href="{{BASE_PATH}}running-on-mesos.html">Mesos cluster in "coarse-grained" sharing mode</a>, - how many CPU cores to request at most. The default will use all available cores. + When running on a <a href="{{HOME_PATH}}spark-standalone.html">standalone deploy cluster</a> or a + <a href="{{HOME_PATH}}running-on-mesos.html#mesos-run-modes">Mesos cluster in "coarse-grained" + sharing mode</a>, how many CPU cores to request at most. The default will use all available cores. </td> </tr> </table> @@ -97,7 +97,7 @@ Apart from these, the following properties are also available, and may be useful <td>false</td> <td> If set to "true", runs over Mesos clusters in - <a href="{{BASE_PATH}}running-on-mesos.html">"coarse-grained" sharing mode</a>, + <a href="{{HOME_PATH}}running-on-mesos.html#mesos-run-modes">"coarse-grained" sharing mode</a>, where Spark acquires one long-lived Mesos task on each machine instead of one Mesos task per Spark task. This gives lower-latency scheduling for short queries, but leaves resources in use for the whole duration of the Spark job. diff --git a/docs/ec2-scripts.md b/docs/ec2-scripts.md index faa89b5d56..a7b1d6f200 100644 --- a/docs/ec2-scripts.md +++ b/docs/ec2-scripts.md @@ -1,13 +1,13 @@ --- layout: global -title: Using the Spark EC2 Scripts +title: Running Spark on EC2 --- -This guide describes how to get Spark running on an EC2 cluster, including how to launch clusters, how to run jobs on them, and how to shut them down. It assumes you have already signed up for Amazon EC2 account on the [Amazon Web Services site](http://aws.amazon.com/). The `spark-ec2` script, located in Spark's `ec2` directory, allows you -to launch, manage and shut down Spark clusters on Amazon EC2. It builds -on the [Mesos EC2 script](https://github.com/mesos/mesos/wiki/EC2-Scripts) -in Apache Mesos. +to launch, manage and shut down Spark clusters on Amazon EC2. It automatically sets up Mesos, Spark and HDFS +on the cluster for you. +This guide describes how to use `spark-ec2` to launch clusters, how to run jobs on them, and how to shut them down. +It assumes you've already signed up for an EC2 account on the [Amazon Web Services site](http://aws.amazon.com/). `spark-ec2` is designed to manage multiple named clusters. You can launch a new cluster (telling the script its size and giving it a name), @@ -18,8 +18,7 @@ are derived from the name of the cluster. For example, a cluster named `test-master`, and a number of slave nodes in a security group called `test-slaves`. The `spark-ec2` script will create these security groups for you based on the cluster name you request. You can also use them to -identify machines belonging to each cluster in the EC2 Console or -ElasticFox. +identify machines belonging to each cluster in the Amazon EC2 Console. # Before You Start diff --git a/docs/index.md b/docs/index.md index 795a180353..ec6ecf3cc5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -70,8 +70,8 @@ of `project/SparkBuild.scala`, then rebuilding Spark (`sbt/sbt clean compile`). **Other documents:** * [Configuration]({{HOME_PATH}}configuration.html): customize Spark via its configuration system -* [Tuning guide]({{HOME_PATH}}tuning.html): best practices to optimize performance and memory use -* [API docs (Scaladoc)]({{HOME_PATH}}api/core/index.html) +* [Tuning Guide]({{HOME_PATH}}tuning.html): best practices to optimize performance and memory use +* [API Docs (Scaladoc)]({{HOME_PATH}}api/core/index.html) * [Bagel]({{HOME_PATH}}bagel-programming-guide.html): an implementation of Google's Pregel on Spark * [Contributing to Spark](contributing-to-spark.html) diff --git a/docs/running-on-mesos.md b/docs/running-on-mesos.md index 24b7b38e51..d9c9c897aa 100644 --- a/docs/running-on-mesos.md +++ b/docs/running-on-mesos.md @@ -3,9 +3,9 @@ layout: global title: Running Spark on Mesos --- -To run on a cluster, Spark uses the [Apache Mesos](http://incubator.apache.org/mesos/) resource manager. Follow the steps below to install Mesos and Spark: +Spark can run on private clusters managed by the [Apache Mesos](http://incubator.apache.org/mesos/) resource manager. Follow the steps below to install Mesos and Spark: -1. Download and build Spark using the instructions [here]({{ HOME_DIR }}Home). +1. Download and build Spark using the instructions [here]({{HOME_PATH}}index.html). 2. Download Mesos 0.9.0 from a [mirror](http://www.apache.org/dyn/closer.cgi/incubator/mesos/mesos-0.9.0-incubating/). 3. Configure Mesos using the `configure` script, passing the location of your `JAVA_HOME` using `--with-java-home`. Mesos comes with "template" configure scripts for different platforms, such as `configure.macosx`, that you can run. See the README file in Mesos for other options. **Note:** If you want to run Mesos without installing it into the default paths on your system (e.g. if you don't have administrative privileges to install it), you should also pass the `--prefix` option to `configure` to tell it where to install. For example, pass `--prefix=/home/user/mesos`. By default the prefix is `/usr/local`. 4. Build Mesos using `make`, and then install it using `make install`. @@ -18,17 +18,39 @@ To run on a cluster, Spark uses the [Apache Mesos](http://incubator.apache.org/m * On all nodes, edit `<prefix>/var/mesos/deploy/mesos.conf` and add the line `master=HOST:5050`, where HOST is your master node. * Run `<prefix>/sbin/mesos-start-cluster.sh` on your master to start Mesos. If all goes well, you should see Mesos's web UI on port 8080 of the master machine. * See Mesos's README file for more information on deploying it. -8. To run a Spark job against the cluster, when you create your `SparkContext`, pass the string `HOST:5050` as the first parameter, where `HOST` is the machine running your Mesos master. In addition, pass the location of Spark on your nodes as the third parameter, and a list of JAR files containing your JAR's code as the fourth (these will automatically get copied to the workers). For example: +8. To run a Spark job against the cluster, when you create your `SparkContext`, pass the string `mesos://HOST:5050` as the first parameter, where `HOST` is the machine running your Mesos master. In addition, pass the location of Spark on your nodes as the third parameter, and a list of JAR files containing your JAR's code as the fourth (these will automatically get copied to the workers). For example: {% highlight scala %} -new SparkContext("HOST:5050", "My Job Name", "/home/user/spark", List("my-job.jar")) +new SparkContext("mesos://HOST:5050", "My Job Name", "/home/user/spark", List("my-job.jar")) {% endhighlight %} -## Running on Amazon EC2 - If you want to run Spark on Amazon EC2, you can use the Spark [EC2 launch scripts]({{HOME_PATH}}ec2-scripts.html), which provide an easy way to launch a cluster with Mesos, Spark, and HDFS pre-configured. This will get you a cluster in about five minutes without any configuration on your part. -## Running Alongside Hadoop +# Mesos Run Modes + +Spark can run over Mesos in two modes: "fine-grained" and "coarse-grained". In fine-grained mode, which is the default, +each Spark task runs as a separate Mesos task. This allows multiple instances of Spark (and other applications) to share +machines at a very fine granularity, where each job gets more or fewer machines as it ramps up, but it comes with an +additional overhead in launching each task, which may be inappropriate for low-latency applications that aim for +sub-second Spark operations (e.g. interactive queries or serving web requests). The coarse-grained mode will instead +launch only *one* long-running Spark task on each Mesos machine, and dynamically schedule its own "mini-tasks" within +it. The benefit is much lower startup overhead, but at the cost of reserving the Mesos resources for the complete duration +of the job. + +To run in coarse-grained mode, set the `spark.mesos.coarse` system property to true *before* creating your SparkContext: + +{% highlight scala %} +System.setProperty("spark.mesos.coarse", "true") +val sc = new SparkContext("mesos://HOST:5050", "Job Name", ...) +{% endhighlight %} + +In addition, for coarse-grained mode, you can control the maximum number of resources Spark will acquire. By default, +it will acquire *all* cores in the cluster (that get offered by Mesos), which only makes sense if you run just a single +job at a time. You can cap the maximum number of cores using `System.setProperty("spark.cores.max", "10")` (for example). +Again, this must be done *before* initializing a SparkContext. + + +# Running Alongside Hadoop You can run Spark and Mesos alongside your existing Hadoop cluster by just launching them as a separate service on the machines. To access Hadoop data from Spark, just use a hdfs:// URL (typically `hdfs://<namenode>:9000/path`, but you can find the right URL on your Hadoop Namenode's web UI). diff --git a/docs/running-on-yarn.md b/docs/running-on-yarn.md index 19e7aede27..081b67ae1e 100644 --- a/docs/running-on-yarn.md +++ b/docs/running-on-yarn.md @@ -3,14 +3,22 @@ layout: global title: Launching Spark on YARN --- -Spark allows you to launch jobs on an existing [YARN](http://hadoop.apache.org/docs/r2.0.1-alpha/hadoop-yarn/hadoop-yarn-site/YARN.html) cluster. +Spark 0.6 adds experimental support for running over a [YARN (Hadoop +NextGen)](http://hadoop.apache.org/docs/r2.0.1-alpha/hadoop-yarn/hadoop-yarn-site/YARN.html) cluster. +Because YARN depends on version 2.0 of the Hadoop libraries, this currently requires checking out a +separate branch of Spark, called `yarn`, which you can do as follows: + + git clone git://github.com/mesos/spark + cd spark + git checkout -b yarn --track origin/yarn + # Preparations -- In order to distribute Spark within the cluster it must be packaged into a single JAR file. This can be done by running `sbt/sbt assembly` -- Your application code must be packaged into a separate jar file. +- In order to distribute Spark within the cluster, it must be packaged into a single JAR file. This can be done by running `sbt/sbt assembly` +- Your application code must be packaged into a separate JAR file. -If you want to test out the YARN deployment mode, you can use the current spark examples. A `spark-examples_2.9.1-0.6.0-SNAPSHOT.jar` file can be generated by running `sbt/sbt package`. +If you want to test out the YARN deployment mode, you can use the current Spark examples. A `spark-examples_2.9.1-0.6.0-SNAPSHOT.jar` file can be generated by running `sbt/sbt package`. # Launching Spark on YARN diff --git a/docs/scala-programming-guide.md b/docs/scala-programming-guide.md index ffc11d8972..28e7bdd4c9 100644 --- a/docs/scala-programming-guide.md +++ b/docs/scala-programming-guide.md @@ -51,7 +51,7 @@ The master URL passed to Spark can be in one of the following formats: <tr><td> spark://HOST:PORT </td><td> Connect to the given <a href="{{HOME_PATH}}spark-standalone.html">Spark standalone cluster</a> master. The port must be whichever one your master is configured to use, which is 7077 by default. </td></tr> -<tr><td> mesos://HOST:PORT </td><td> Connect Spark to the given <a href="{{HOME_PATH}}running-on-mesos.html">Mesos</a> cluster. +<tr><td> mesos://HOST:PORT </td><td> Connect to the given <a href="{{HOME_PATH}}running-on-mesos.html">Mesos</a> cluster. The host parameter is the hostname of the Mesos master. The port must be whichever one the master is configured to use, which is 5050 by default. </td></tr> diff --git a/docs/spark-standalone.md b/docs/spark-standalone.md index f0bebcf3d9..7bad006a23 100644 --- a/docs/spark-standalone.md +++ b/docs/spark-standalone.md @@ -10,77 +10,143 @@ TODO(andyk): - Say the scripts will guess the resource amounts (i.e. # cores) automatically {% endcomment %} -In addition to running on top of [Mesos](https://github.com/mesos/mesos), Spark also supports a standalone mode, consisting of one Spark master and several Spark worker processes. You can run the Spark standalone mode either locally or on a cluster. If you wish to run an Spark Amazon EC2 cluster using standalone mode we have provided [a set of scripts](ec2-scripts.html) that make it easy to do so. +In addition to running on top of [Mesos](https://github.com/mesos/mesos), Spark also supports a standalone mode, consisting of one Spark master and several Spark worker processes. You can run the Spark standalone mode either locally (for testing) or on a cluster. If you wish to run on a cluster, we have provided [a set of deploy scripts](#cluster-launch-scripts) to launch a whole cluster. -## Getting Started +# Getting Started -Download and compile Spark as described in the [Getting Started Guide](index.html). You do not need to install Mesos on your machine if you are using the standalone mode. +Compile Spark with `sbt package` as described in the [Getting Started Guide](index.html). You do not need to install Mesos on your machine if you are using the standalone mode. -## Standalone Mode Configuration - -The `conf/spark_env.sh` file contains several configuration parameters for the standalone mode. Here is a quick overview: - -- SPARK\_MASTER\_IP - Use this to bind the master to a particular ip address, for example a public one. (Default: local ip address) -- SPARK\_MASTER\_PORT - Start the spark master on a different port (Default: 7077) -- SPARK\_MASTER\_WEBUI\_PORT - Specify a different port for the Master WebUI (Default: 8080) -- SPARK\_WORKER\_PORT - Start the spark worker on a specific port (Default: random) -- SPARK\_WORKER\_CORES - Specify the number of cores to use (Default: all available cores) -- SPARK\_WORKER\_MEMORY - Specify how much memory to use, e.g. 1000M, 2G (Default: MAX(Available - 1024MB, 512MB)) -- SPARK\_WORKER\_WEBUI\_PORT - Specify a different port for the Worker WebUI (Default: 8081) - -## Starting the standalone Master +# Starting a Cluster Manually You can start a standalone master server by executing: ./run spark.deploy.master.Master -The program takes additional arguments that will overwrite the configuration values: - - -i IP, --ip IP IP address or DNS name to listen on - -p PORT, --port PORT Port to listen on (default: 7077) - --webui-port PORT Port for web UI (default: 8080) - -The master process should print out the Master's URL of the form `spark://IP:PORT` which you can use to create a `SparkContext` in your applications. - -## Starting standalone Workers - -Similar to the master, you can start one or more standalone workers via: - -`./run spark.deploy.worker.Worker spark://IP:PORT` - -The following options can be passed to the worker: - - -c CORES, --cores CORES Number of cores to use - -m MEM, --memory MEM Amount of memory to use (e.g. 1000M, 2G) - -i IP, --ip IP IP address or DNS name to listen on - -p PORT, --port PORT Port to listen on (default: random) - --webui-port PORT Port for web UI (default: 8081) - -## Debugging a standalone cluster +Once started, the master will print out a `spark://IP:PORT` URL for itself, which you can use to connect workers to it, +or pass as the "master" argument to `SparkContext` to connect a job to the cluster. You can also find this URL on +the master's web UI, which is [http://localhost:8080](http://localhost:8080) by default. + +Similarly, you can start one or more workers and connect them to the master via: + + ./run spark.deploy.worker.Worker spark://IP:PORT + +Once you have started a worker, look at the master's web UI ([http://localhost:8080](http://localhost:8080) by default). +You should see the new node listed there, along with its number of CPUs and memory (minus one gigabyte left for the OS). + +Finally, the following configuration options can be passed to the master and worker: + +<table class="table"> + <tr><th style="width:21%">Argument</th><th>Meaning</th></tr> + <tr> + <td><code>-i IP</code>, <code>--ip IP</code></td> + <td>IP address or DNS name to listen on</td> + </tr> + <tr> + <td><code>-p PORT</code>, <code>--port PORT</code></td> + <td>IP address or DNS name to listen on (default: 7077 for master, random for worker)</td> + </tr> + <tr> + <td><code>--webui-port PORT</code></td> + <td>Port for web UI (default: 8080 for master, 8081 for worker)</td> + </tr> + <tr> + <td><code>-c CORES</code>, <code>--cores CORES</code></td> + <td>Number of CPU cores to use (default: all available); only on worker</td> + </tr> + <tr> + <td><code>-m MEM</code>, <code>--memory MEM</code></td> + <td>Amount of memory to use, in a format like 1000M or 2G (default: your machine's total RAM minus 1 GB); only on worker</td> + </tr> + <tr> + <td><code>-d DIR</code>, <code>--work-dir DIR</code></td> + <td>Directory to use for scratch space and job output logs (default: SPARK_HOME/work); only on worker</td> + </tr> +</table> + + +# Cluster Launch Scripts + +To launch a Spark standalone cluster with the deploy scripts, you need to set up two files, `conf/spark-env.sh` and `conf/slaves`. The `conf/spark-env.sh` file lets you specify global settings for the master and slave instances, such as memory, or port numbers to bind to, while `conf/slaves` is a list of slave nodes. The system requires that all the slave machines have the same configuration files, so *copy these files to each machine*. + +In `conf/spark-env.sh`, you can set the following parameters, in addition to the [standard Spark configuration settongs]({{HOME_PATH}}configuration.html): + +<table class="table"> + <tr><th style="width:21%">Environment Variable</th><th>Meaning</th></tr> + <tr> + <td><code>SPARK_MASTER_IP</code></td> + <td>Bind the master to a specific IP address, for example a public one</td> + </tr> + <tr> + <td><code>SPARK_MASTER_PORT</code></td> + <td>Start the master on a different port (default: 7077)</td> + </tr> + <tr> + <td><code>SPARK_MASTER_WEBUI_PORT</code></td> + <td>Port for the master web UI (default: 8080)</td> + </tr> + <tr> + <td><code>SPARK_WORKER_PORT</code></td> + <td>Start the Spark worker on a specific port (default: random)</td> + </tr> + <tr> + <td><code>SPARK_WORKER_CORES</code></td> + <td>Number of cores to use (default: all available cores)</td> + </tr> + <tr> + <td><code>SPARK_WORKER_MEMORY</code></td> + <td>How much memory to use, e.g. 1000M, 2G (default: total memory minus 1 GB)</td> + </tr> + <tr> + <td><code>SPARK_WORKER_WEBUI_PORT</code></td> + <td>Port for the worker web UI (default: 8081)</td> + </tr> + <tr> + <td><code>SPARK_WORKER_DIR</code></td> + <td>Directory to run jobs in, which will include both logs and scratch space (default: SPARK_HOME/work)</td> + </tr> +</table> + +In `conf/slaves`, include a list of all machines where you would like to start a Spark worker, one per line. The master machine must be able to access each of the slave machines via password-less `ssh` (using a private key). For testing purposes, you can have a single `localhost` entry in the slaves file. + +Once you've set up these configuration files, you can launch or stop your cluster with the following shell scripts, based on Hadoop's deploy scripts, and available in `SPARK_HOME/bin`: + +- `bin/start-master.sh` - Starts a master instance on the machine the script is executed on. +- `bin/start-slaves.sh` - Starts a slave instance on each machine specified in the `conf/slaves` file. +- `bin/start-all.sh` - Starts both a master and a number of slaves as described above. +- `bin/stop-master.sh` - Stops the master that was started via the `bin/start-master.sh` script. +- `bin/stop-slaves.sh` - Stops the slave instances that were started via `bin/start-slaves.sh`. +- `bin/stop-all.sh` - Stops both the master and the slaves as described above. + +Note that the scripts must be executed on the machine you want to run the Spark master on, not your local machine. + + +# Connecting a Job to the Cluster + +To run a job on the Spark cluster, simply pass the `spark://IP:PORT` URL of the master as to the [`SparkContext` +constructor]({{HOME_PATH}}scala-programming-guide.html#initializing-spark). + +To run an interactive Spark shell against the cluster, run the following command: + + MASTER=spark://IP:PORT ./spark-shell + + +# Job Scheduling + +The standalone cluster mode currently only supports a simple FIFO scheduler across jobs. +However, to allow multiple concurrent jobs, you can control the maximum number of resources each Spark job will acquire. +By default, it will acquire *all* the cores in the cluster, which only makes sense if you run just a single +job at a time. You can cap the number of cores using `System.setProperty("spark.cores.max", "10")` (for example). +This value must be set *before* initializing your SparkContext. + + +# Monitoring and Logging + +Spark's standalone mode offers a web-based user interface to monitor the cluster. The master and each worker has its own web UI that shows cluster and job statistics. By default you can access the web UI for the master at port 8080. The port can be changed either in the configuration file or via command-line options. + +In addition, detailed log output for each job is also written to the work directory of each slave node (`SPARK_HOME/work` by default). You will see two files for each job, `stdout` and `stderr`, with all output it wrote to its console. + + +# Running Alongside Hadoop -Spark offers a web-based user interface in the standalone mode. The master and each worker has its own WebUI that shows cluster and job statistics. By default you can access the WebUI for the master at port 8080. The port can be changed either in the configuration file or via command-line options. +You can run Spark alongside your existing Hadoop cluster by just launching it as a separate service on the machines. To access Hadoop data from Spark, just use a hdfs:// URL (typically `hdfs://<namenode>:9000/path`, but you can find the right URL on your Hadoop Namenode's web UI). Alternatively, you can set up a separate cluster for Spark, and still have it access HDFS over the network; this will be slower than disk-local access, but may not be a concern if you are still running in the same local area network (e.g. you place a few Spark machines on each rack that you have Hadoop on). -Detailed log output for the jobs is written to the `work` drectory by default. - -## Running on a Cluster - -In order to run a Spark standalone cluster there are two main points of configuration, the `conf/spark-env.sh` file (described above), and the `conf/slaves` file. the `conf/spark-env.sh` file lets you specify global settings for the master and slave instances, such as memory, or port numbers to bind to. We are assuming that all your machines share the same configuration parameters. - -The `conf/slaves` file contains a list of all machines where you would like to start a Spark slave (worker) instance when using the scripts below. The master machine must be able to access each of the slave machines via ssh. For testing purposes, you can have a single `localhost` entry in the slaves file. - -In order to make starting master and slave instances easier, we have provided Hadoop-style shell scripts. The scripts can be found in the `bin` directory. A quick overview: - -- `bin/start_master` - Starts a master instance on the machine the script is executed on. -- `bin/start_slaves` - Starts a slave instance on each machine specified in the `conf/slaves` file. -- `bin/start_all` - Starts both a master and a number of slaves as described above. -- `bin/stop_master` - Stops the master that was started via the `bin/start_master` script. -- `bin/stop_slaves` - Stops the slave intances that were started via the `bin/start_slaves` script. -- `bin/stop_all` - Stops both the master and the slaves as described above. - -Note that the scripts must be executed on the machine you want to start the Spark master on, not your local machine. - -{% comment %} -## EC2 Scripts - -To save you from needing to set up a cluster of Spark machines yourself, we provide a set of scripts that launch Amazon EC2 instances with a preinstalled Spark distribution. These scripts are identical to the [EC2 Mesos Scripts](https://github.com/mesos/spark/wiki/EC2-Scripts), except that you need to execute `ec2/spark-ec2` with the following additional parameters: `--cluster-type standalone -a standalone`. Note that the Spark version on these machines may not reflect the latest changes, so it may be a good idea to ssh into the machines and merge the latest version from github. -{% endcomment %} |