Spark official documentation-Standalone Mode)

Source: Internet
Author: User

BesidesDeploymentOn Mesos, Spark also supportsIndependentDeploymentModeIncluding one Spark master process and multiple Spark worker processes.IndependentDeploymentModeIt can be run on a single machine for testing, orDeploymentOn the cluster. If you planDeploymentOn the cluster, you can useDeploymentScript to start a cluster.

Start now

Use sbt package to compile the SDK. For more information, see the start guide. If you planDeploymentSeparateModeYou do not need to install Mesos.

Start a cluster manually

Run the following command to start a separateModeMaster service:

./Runspark. deploy. master. Master

Once started, the master will output spark: // IP: PORT to prompt the connection to workers. You can also use the parameter "master" to connect to the Cluster Job through SparkContext. You can see this address on the master web management interface, which is http: // localhost: 8080 by default.

Similarly, you can start one or more workers and use the following statement to connect the sum master. :

./Runspark. deploy. worker. Worker spark: // IP: PORT

After a worker is started, view the master's web Management Interface (http: // localhost: 8080 by default), which lists the CPU and memory information of the newly added nodes. (Excluding the memory space reserved for the operating system ).

Finally, the following configuration options can be passed to the masterand worker:

Parameters

Description

-I IP, -- ip IP

IP address or DNS machine name to listen

-P PORT, -- port PORT

Port to be listened on (default: master 7077; random worker)

-- Webui-port PORT

Web UI port (default: master 8080, worker 8081)

-C CORES, -- cores CORES

Number of CPU cores available for jobs (default: all available );

Only on worker.

-M MEM, -- memory MEM

Memory capacity available for the job. The default format is MB or 2 GB (default: 1 GB for the operating system to remove all RAM); only on the worker.

-D DIR, -- work-dir DIR

Directory path for scaling space and log Input

(Default: SPARK_HOME/work); only on worker.

Cluster Startup Script

Start separatelyModeWhen creating a cluster, first create a configuration file conf/slaves in the Spark directory to list the machine names of all worker machines, each of which occupies one row. The Master must be able to log on to the worker machine using ssh locakhost without a password.

Then, run the shell script in the SPARK_HOME/bin path to start or stop the cluster.

L bin/start-master.sh-Starts amaster instance on the machine the script is executed on.

L bin/start-slaves.sh-Starts aslave instance on each machine specified in the conf/slaves file.

L bin/start-all.sh-Starts botha master and a number of slaves as described above.

L bin/stop-master.sh-Stops themaster that was started via the bin/start-master.sh script.

L bin/stop-slaves.sh-Stops theslave instances that were started via bin/start-slaves.sh.

L bin/stop-all.sh-Stops boththe master and the slaves as described above.

Note: You can only execute the above script on the master host running Spark, instead of your local machine.

You can further configure the environment variables for the entire cluster through the conf/spark-env.sh. This file can be generated using conf/spark-env.sh.template as a template copy. Then, copy to allWorkerIt works on the machine. The following are some optional parameters and their meanings:

Environment Variable

Description

SPARK_MASTER_IP

Bind an external IP address to the master

SPARK_MASTER_PORT

Start master from another port (default: 7077)

SPARK_MASTER_WEBUI_PORT

Web UI port of the Master node (default: 8080)

SPARK_WORKER_PORT

Dedicated port for starting Spark worker (default: Random)

SPARK_WORKER_DIR

Directory path for scaling space and log Input

(Default: SPARK_HOME/work );

SPARK_WORKER_CORES

Number of CPU cores available for jobs (default: all available );

SPARK_WORKER_MEMORY

Memory capacity available for jobs. The default format is MB or 2 GB (default: 1 GB for all RAM resources to be removed from the operating system). Note: the memory space of each job is determined by SPARK_MEM.

SPARK_WORKER_WEBUI_PORT

Web UI startup port of worker (default: 8081)

SPARK_DAEMON_MEMORY

Memory space allocated to the Spark master and worker daemon (default: 512 MB)

SPARK_DAEMON_JAVA_OPTS

JVM options for Spark master and worker daemon (default: none)

Submit job to cluster

To run a job in a Spark cluster, you only need to send the spark: // IP: PORT connected to the master to the SparkContext constructor.

Run the following command to run an interactive Spark shell on the cluster:

MASTER = spark: // IP: PORT./spark-shell

Job Scheduling

SeparateDeploymentModeCurrently, only the FIFO Job Scheduling Policy is supported. However, to allow concurrent job execution, you can control the maximum value of resources that each job can obtain. By default, if there is only one job in the system, it will obtain all resources. Use a statement similar to System. setProperty ("spark. cores. max", "10") to obtain the number of kernels. This value must be set before SparkContext initialization.

Monitoring and logging

Spark separatelyDeploymentModeProvides a WEB-based cluster monitor. The master and each worker have a web ui to display the cluster statistics. By default, you can access the web ui of the master through port 8080. You can also modify the port value through the configuration file or command.

In addition, detailed log output for each job is also written to the workdirectory of each slave node (SPARK_HOME/work by default ). you will see two files for each job, with all output itwrote to its console.

In addition, the running logs of jobs on each slave node are recorded in the default SPARK_HOME/work directory in detail. Each job corresponds to two files, stdout and stderr, which contain all historical output on the console.

Run together with Hadoop

AsIndependentAnd the existing Hadoop cluster.

Through hdfs: // URL, Spark can accessData. (For example, the address can be written as hdfs: // <namenode>: 9000/path, and a more precise URL can be obtained from the Namenode web UI ). alternatively, you can build a cluster for Spark to accessDataIn this way, it is better to access the localDataFast, unless they are all in the same LAN. (For example, several Spark machines and Hadoop clusters are on the same rack ).

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.