本文介紹安裝spark單機環境的方法,可用於測試及開發。主要分紅如下4部分:
(1)環境準備
(2)安裝scala
(3)安裝spark
(4)驗證安裝狀況
一、環境準備
(1)配套軟件版本要求:Spark runs on Java 6+ and Python 2.6+. For the Scala API, Spark 1.3.1 uses Scala 2.10. You will need to use a compatible Scala version (2.10.x).
(2)安裝好linux、jdk、python, 通常linux均會自帶安裝好jdk與python,但注意jdk默認爲openjdk,建議從新安裝oracle jdk。
(3)IP:10.171.29.191 hostname:master
二、安裝scala
(1)下載scala
wget http://downloads.typesafe.com/scala/2.10.5/scala-2.10.5.tgz
(2)解壓文件
tar -zxvf scala-2.10.5.tgz
(3)配置環境變量
#vi/etc/profile
#SCALA VARIABLES START
export SCALA_HOME=/home/jediael/setupfile/scala-2.10.5
export PATH=$PATH:$SCALA_HOME/bin
#SCALA VARIABLES END
$ source /etc/profile
$ scala -version
Scala code runner version 2.10.5 -- Copyright 2002-2013, LAMP/EPFL
(4)驗證scala
$ scala
Welcome to Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> 9*9
res0: Int = 81
三、安裝spark
(1)下載spark
wget http://mirror.bit.edu.cn/apache/spark/spark-1.3.1/spark-1.3.1-bin-hadoop2.6.tgz
(2)解壓spark
tar -zxvf http://mirror.bit.edu.cn/apache/spark/spark-1.3.1/spark-1.3.1-bin-hadoop2.6.tgz
(3)配置環境變量
#vi/etc/profile
#SPARK VARIABLES START
export SPARK_HOME=/mnt/jediael/spark-1.3.1-bin-hadoop2.6
export PATH=$PATH:$SPARK_HOME/bin
#SPARK VARIABLES END
$ source /etc/profile
(4)配置spark
$ pwd
/mnt/jediael/spark-1.3.1-bin-hadoop2.6/conf
$ mv spark-env.sh.template spark-env.sh
$vi spark-env.sh
export SCALA_HOME=/home/jediael/setupfile/scala-2.10.5
export JAVA_HOME=/usr/java/jdk1.7.0_51
export SPARK_MASTER_IP=10.171.29.191
export SPARK_WORKER_MEMORY=512m
export master=spark://10.171.29.191:7070
$vi slaves
master
(5)啓動spark
pwd
/mnt/jediael/spark-1.3.1-bin-hadoop2.6/sbin
$ ./start-all.sh
注意,hadoop也有start-all.sh腳本,所以必須進入具體目錄執行腳本
$ jps
30302 Worker
30859 Jps
30172 Master
四、驗證安裝狀況
(1)運行自帶示例
$ bin/run-example org.apache.spark.examples.SparkPi
(2)查看集羣環境
http://master:8080/
(3)進入spark-shell
$spark-shell
(4)查看jobs等信息
http://master:4040/jobs/
java
版權聲明:本文爲博主原創文章,未經博主容許不得轉載。python