对于Spark1.3进行编译

编译其实是按照官方文档进行的,比较简单,文档地址是:http://spark.apache.org/docs/latest/building-spark.html

编译命令最终是:

先要执行:

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

然后再执行:

build/mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package

解释一下:

环境背景:Linux/CentOS

build是spark源代码根目录中的目录

机器中一定是要安装maven啦

-Pyarn -Phadoop-2.4:  可以根据实际情况来选择是否需要支持yarn和hdfs。 然后为他们进行版本的选择。 我这里yarn和hdfs都是2.4版本,所以只填写一次就行。

-DskipTests 使用后代表是不需要再执行测试用例 

clean package 就是清空历史编译后文件,并重新进行编译。

 

另外,编译时是需要下载许多许多的依赖包的,所以一定要用国内的maven映射点,例如是这样:

<mirror>

              <id>nexus-osc</id>

              <mirrorOf>*</mirrorOf>

              <name>Nexus osc</name>

              <url>http://maven.oschina.net/content/groups/public/</url>

       </mirror>

 

补充一下:

1、如果编译时断掉后,那么重新再开始编译即可。

2、 spark1.3.1中对于2.x只支持2.2,2.3,2.4四个版本。 更高版本和更低版本是不支持的。

 

2015-04-30 15:00:00 再次补充一下:

编译时MQTT总是编译不过去,网上找了许久也没有找到解决办法,报错信息如下:

[ERROR] Failed to execute goal on project spark-streaming-mqtt_2.10: Could not resolve dependencies for project org.apache.spark:spark-streaming-mqtt_2.10:jar:1.3.1: Failure to find org.eclipse.paho:org.eclipse.paho.client.mqttv3:jar:1.0.1 in http://maven.oschina.net/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus-osc has elapsed or updates are forced -> [Help 1]

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

[ERROR] 

[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :spark-streaming-mqtt_2.10

似乎是spark-streaming-mqtt_2.10这个没有找到,我找了找好象也没有找到。 

最后反正我也用不到mqtt,所以就将pom中的mqtt删除了。即,将根目录下的pom.xml中的

<module>external/mqtt</module>

给注释掉了

 

补充,如何生成部署包:

参考的http://blog.csdn.net/book_mmicky/article/details/25714445

执行

./make-distribution.sh --tgz --with-tachyon -Phadoop-2.4 -Pyarn -Phive

生成的文件在根目录,拿该文件部署即可

 

再补充一下,部署包执行上边的命令时总是生成失败。 但把--with-tachyon去掉就能成功。 奇怪了,我去读一下代码看看。

 

再再补充一下,这是我编译的部署包,spark1.3.1然后是to hadoop2.4.0的, 没有把tachyon打进去,因为选择打进去后发现部署包出不来,猜测是mak-distribution.sh出现了错误

http://pan.baidu.com/s/1jGKin2Y

 

再再再补充一下,这是我编译的hadoop2.4.0的部署包

http://pan.baidu.com/s/1i329zt7

你可能感兴趣的:(spark)