一、下載scala2.11.5版本,下載地址爲:
http://www.scala-lang.org/download/2.11.5.html 二、安裝和配置scala: 第一步:上傳scala安裝包 並解壓
![](http://static.javashuo.com/static/loading.gif)
第二步 配置SCALA_HOME環境變量到bash_profile
![](http://static.javashuo.com/static/loading.gif)
第三步 source 使配置環境變量生效:
![](http://static.javashuo.com/static/loading.gif)
第四步 驗證scala:
![](http://static.javashuo.com/static/loading.gif)
三、下載spark 1.2.0,具體下載地址:
http://spark.apache.org/downloads.html 四、安裝和配置spark: 第一步 解壓spark:
![](http://static.javashuo.com/static/loading.gif)
第二步 配置SPARK_HOME環境變量:
![](http://static.javashuo.com/static/loading.gif)
第三步 使用source生效:
![](http://static.javashuo.com/static/loading.gif)
進入spark的conf目錄: 第四步 修改slaves文件,首先打開該文件:
![](http://static.javashuo.com/static/loading.gif)
slaves修改後:
![](http://static.javashuo.com/static/loading.gif)
第五步 配置spark-env.sh 首先把spark-env.sh.template拷貝到spark-env.sh:
![](http://static.javashuo.com/static/loading.gif)
而後 打開「spark-env.sh」文件:
![](http://static.javashuo.com/static/loading.gif)
spark-env.sh文件修改後:
![](http://static.javashuo.com/static/loading.gif)
五、啓動spark僞分佈式幫查看信息: 第一步 先保證hadoop集羣或者僞分佈式啓動成功,使用jps看下進程信息:
![](http://static.javashuo.com/static/loading.gif)
若是沒有啓動,進入hadoop的sbin目錄執行 ./start-all.sh 第二步 啓動spark: 進入spark的sbin目錄下執行「start-all.sh」:
![](http://static.javashuo.com/static/loading.gif)
此刻 咱們看到有新進程「Master」 和"Worker" 咱們訪問「http://master:8080/」,進如spark的web控制檯頁面:
![](http://static.javashuo.com/static/loading.gif)
從頁面上能夠看到一個Worker節點的信息。 咱們進入spark的bin目錄,使用「spark-shell」控制檯:
![](http://static.javashuo.com/static/loading.gif)
經過訪問"http://master:4040",進入spark-shell web控制檯頁面:
![](http://static.javashuo.com/static/loading.gif)
六、測試spark僞分佈式: 咱們使用以前上傳到hdfs中的/data/test/README.txt文件進行mapreduce 取得hdfs文件:
![](http://static.javashuo.com/static/loading.gif)
對讀取的文件進行一下操做:
![](http://static.javashuo.com/static/loading.gif)
使用collect命令提交併執行job: readmeFile.collect
![](http://static.javashuo.com/static/loading.gif)
查看spark-shell web控制檯:
![](http://static.javashuo.com/static/loading.gif)
states:
![](http://static.javashuo.com/static/loading.gif)
端口整理: master端口是7077 master webui是8080 spark shell webui端口是4040