Spark3.0源码编译打包
前⾔
Spark3.0已经发布有⼀阵⼦了,官⽅发布了预览版,带来了⼀⼤波更新,对于我们程序员来说,⾸先当然是代码拉过来,打个包,跑起来!!
源码地址
Spark源码是托管在github上⾯的,源码地址:
不过clone下了还是⽼费劲,不得琢磨琢磨微软收购github之后这个中国的⽹速问题不知道他们怎么看,我在gitee上⾯直接也fork⼀份源码,再进⾏clone。
编译和打包
作为⼀个过(被)来(虐)⼈,编译之前需要做点⼯作,后续就顺利很多。
直接编译会出现下⾯的错误:
......
exec: curl --silent --show-error -L downloads.lightbend/zinc/0.3.15/zinc-0.
curl: (77) error setting certificate verify locations:
......
exec: curl --silent --show-error -L downloads.lightbend/scala/2.12.10/scala-2.
......
/home/hdfs/Spark3.0/build/mvn: line 130: cd: /home/hdfs/Spark3.0/build/scala-2.12.10/bin/../lib: No such file or directory
/home/hdfs/Spark3.0/build/mvn: line 131: cd: /home/hdfs/Spark3.0/build/scala-2.12.10/bin/../lib: No such file or directory
exec: curl --silent --show-error -L /dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.
......
/
home/hdfs/Spark3.0/build/mvn: line 148: /home/hdfs/Spark3.0/build/zinc-0.3.15/bin/zinc: No such file or directory
......
这个时候⼀定要淡定,这⾥的信息其实是编译的时候需要依赖apache-maven-3.6.、scala-2.、zinc-0.,如果不存在则会⾃动下载,但是下载其实是失败的,我们选择⼿动下载这⼏个包,放在build⾥⾯解压好
接下来我们执⾏:
/dev/make-distribution.sh --name spark-3.0 --tgz -Phadoop-2.6 -Phive -Phive-thriftserver -Pyarn -DskipTests
脚本是不报错了,但是⼀直卡着
我们到脚本,129⾏开始的地⽅:
VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ \
| grep -v "INFO"\
| grep -v "WARNING"\
|tail -n 1)
SCALA_VERSION=$("$MVN" help:evaluate -Dexpression=scala.binary.version $@ \
| grep -v "INFO"\
| grep -v "WARNING"\
|tail -n 1)
SPARK_HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ \
| grep -v "INFO"\
| grep -v "WARNING"\
|tail -n 1)
SPARK_HIVE=$("$MVN" help:evaluate -Dexpression=project.activeProfiles -pl sql/hive $@ \
| grep -v "INFO"\
| grep -v "WARNING"\
| fgrep --count "<id>hive</id>";\
# Reset exit status to 0, otherwise the script stops here if the last grep finds nothing\
# because we use "set -o pipefail"
echo -n)
这个地⽅是获获取各个组件的版本,其实版本从maven的l中可以看到,我直接写成固定的就⾏,改成如下:
VERSION=3.1.0-SNAPSHOT
SCALA_VERSION=2.12
SPARK_HADOOP_VERSION=2.7.4
SPARK_HIVE=3.2
另外,我们为了执⾏下载的时候速度快些,我们把maven的仓库地址换掉:
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>maven.aliyun/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
再次编译,可以动了:
接下来就是等待了,编译完成之后会就可以看到我们的包了
⼀些编译过程中的⼩问题
FullGC的问题
编译这个⼯作需要多试⼏次,编译的时候我发现还有本⾝maven慢的问题
[hdfs@daas-service-01 ~]$ jps -ml
dehaus.plexus.classworlds.launcher.Launcher -DzincPort=3030 clean package -DskipTests -Phadoop-2.6 -Phive -Phive-thriftserver -Pyarn -D skipTests
[hdfs@daas-service-01 ~]$ jstat -gcutil 789041000
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
71.260.0021.629.5391.0595.8680 4.0217 2.064 6.085
71.260.0034.029.5391.0595.8680 4.0217 2.064 6.085
71.260.0043.849.5391.0595.8680 4.0217 2.064 6.085
71.260.0055.639.5391.0595.8680 4.0217 2.064 6.085
71.260.0073.309.5391.0595.8680 4.0217 2.064 6.085
71.260.0087.289.5391.0595.8680 4.0217 2.064 6.085
0.0077.58 3.999.5391.0695.6981 4.0907 2.064 6.154
0.0077.5811.909.5391.0695.6981 4.0907 2.064 6.154
针对这种现象,我们适度调整JVM的参数:
export MAVEN_OPTS="-Xms12g -Xmx12g -XX:+UseG1GC"
CodeCache 满的问题
编译过程中出现下⾯提⽰
[INFO] Compiling 10 Scala sources to /home/hdfs/Spark3.0/mllib-local/target/scala-2.12/test-classes ...
Java HotSpot(TM)64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
Java HotSpot(TM)64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize= CodeCache: size=245760Kb used=243977Kb max_used=243996Kb free=1782Kb
bounds [0x00002aae10000000, 0x00002aae1f000000, 0x00002aae1f000000]
total_blobs=59407nmethods=58763adapters=539
compilation: disabled (not enough contiguous free space left)
这个其实就是代码缓冲区满了,按照提⽰我们可以适度加⼤这个数值,⼏个参数⼀起配合就是
export MAVEN_OPTS="-Xms12g -Xmx12g -XX:+UseG1GC -XX:ReservedCodeCacheSize=2g"
⼀点⼩总结
⾸先要相信代码是没问题的,这种⼤作肯定是可以打包的
⼤部分情况是⽹络问题,我们需要做点调整或者离线去下载依赖
下载apache我们是程序员,程序员是有改造计算机世界的能⼒,打包什么的真block了,改得他可以通过就⾏spark是可以maven构建的,所以直接安装maven的⽅式去搞就⾏
maven也是java程序,可以按照java程序去调整
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论