Spark的源碼編譯

Spark的版本下載和源碼編譯方法的官方地址:http://spark.apache.org/downloads.html
html

直接進Github,複製源碼:https://github.com/apache/sparkgit


Spark 編譯

  有三種方式:SBT、MAVEN、make-distribution.sh。 SBT、MAVEN兩種方式打出來的包比較大,不適合部署使用。所以咱們一般使用第三種方式打包。github

官方已經提供安裝包了,爲何要本身編譯?apache

  Spark能同Hadoop進行交互,而Hadoop的廠商比較多有不少商業版。Spark官方提供的安裝包不必定和咱們的Hadoop集羣版本相同,若是不相同就有可能出現莫名其妙的錯誤。這時,咱們手工指定相應版本進行編譯是最好選擇。工具

SBT編譯

sbt/sbt clean assembly

MAVEN編譯

  因爲MAVEN工具默認的內存比較小,須要先調大其佔用的內存上限:oop

export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"

  打包ui

mvn clean assembly:assembly

make-distribution.sh構建安裝包

  該腳本會使用MAVEN進行編譯,而後打成一個tgz包。spa

  腳本的使用方法:code

./make-distribution.sh --help

  打包:htm

./make-distribution.sh --tgz --with-tachyon

Hadoop版本對應的MAVEN Profile

Hadoop version Profile required
0.23.x hadoop-0.23
1.x to 2.1.x (none)
2.2.x hadoop-2.2
2.3.x hadoop-2.3
2.4.x hadoop-2.4

Yarn版本對應的MAVEN Profile

YARN version Profile required
0.23.x to 2.1.x yarn-alpha
2.2.x and later yarn

Hive對應的MAVEN Profile

在構造腳本後面添加 -Phive即可

自定義Hadoop版本

  若是要構建hortonworks Hadoop 2.4.0.2.1.4.0-632,所對應的Hadoop版本是2.4.x。所以,相應的Profile爲-Phadoop-2.4 -Pyarn。

編譯方式:

SBT

sbt clean assembly -Phive -Phadoop-2.4 -Pyarn -Dhadoop.version=2.4.0.2.1.4.0-632

Maven

export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
mvn clean assembly:assembly

make-distribution.sh

1.1.x 使用

./make-distribution.sh --tgz --with-tachyon -Phadoop-2.4 -Pyarn -Phive -Dhadoop.version=2.4.0.2.1.4.0-632```

  對於1.1.x之前的版本使用:

./make-distribution.sh --hadoop 2.4.0.2.1.4.0-632 --with-yarn --with-tachyon --tgz

若是yarn的版本和Hadoop的版本不一致可添加

-Dyarn.version=2.4.0.2.1.4.0-632
相關文章
相關標籤/搜索