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
相关文章
相关标签/搜索