Spark編譯
有三種方式:SBT(Simple Build Tool),Maven,Make-distribution.sh
其中SBT,Maven兩種方式打出來的包比較大视卢,因此使用第三種方式編譯
官方已經(jīng)提供了安裝包了,為什么要自己編譯呢?
Spark能同Hadoop進行交互,而Hadoop的廠商比較多有很多商業(yè)版芳来。Spark官方提供的安裝包不一定和我們的Hadoop集群版本相同,如果不相同就有可能出現(xiàn)莫名其妙的錯誤。這時,我們手工指定相應版本進行編譯是最好選擇
SBT編譯
sbt/sbt clean assembly
Maven編譯
由于Maven工具默認的內(nèi)存比較小,需要先調(diào)大其占用的內(nèi)存上限
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
打包
mvn clean assembly:assembly
make-distribution.sh構(gòu)建安裝包
該腳本會使用MAVEN進行編譯妹笆,然后打成一個tgz包。
腳本的使用方法:
./make-distribution.sh --help
打包:
./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
在構(gòu)造腳本后面添加 -Phive便可
自定義Hadoop版本
如果要構(gòu)建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