编译支持hive的spark assembly

原生的spark assembly jar是不依赖hive的,如果要使用spark hql必须将hive相关的依赖包打到spark assembly jar中来。打包方法:

假设已经装好了maven,

1添加环境变量,如果jvm的这些配置太小的话,可能导致在编译过程中出现OOM,因此放大一些:

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


2 cd到spark源码目录,执行:

mvn -Pyarn -Dhadoop.version=2.5.0-cdh5.3.0  -Dscala-2.10.4 -Phive -Phive-thriftserver   -DskipTests clean package

(其实好像用cdh版本的只要写 mvn -Pyarn -Phive  -Phive-thriftserver -DskipTests clean package就可以了)

注意hadoop.version和scala的版本设置成对应的版本

经过漫长的编译过程(我编译了2个半小时),最终成功了,在assembly/target/scala-2.10目录下面有spark-assembly-1.2.0-cdh5.3.0-hadoop2.5.0-cdh5.3.0.jar文件,用rar打开看看hive jdbc package有没有包含在里面,有的话说明编译成功了。


源码目录下面有make-distribution.sh,可以用来打bin包:

 ./make-distribution.sh --name custom-spark --skip-java-test --tgz -Pyarn -Dhadoop.version=2.5.0-cdh5.3.0  -Dscala-2.10.4 -Phive -Phive-thriftserver


If you want IDEA compile your spark project (version 1.0.0 and above), you should do it with following steps.

1 clone spark project
2 use mvn to compile your spark project ( because you need the generated avro source file  in flume-sink module )
3 open spark/pom.xml with IDEA
4 check profiles you need in “maven projects” window
5 modify the source path of  flume-sink module, make “target/scala-2.10/src_managed/main/compiled_avro” as a source path
6 if you checked yarn profile, you need to 
     remove the module "spark-yarn_2.10” 
     add “spark/yarn/common/src/main/scala” and “spark/yarn/stable/src/main/scala” the source path of module “yarn-parent_2.10"
7 then you can run " Build -> Rebuild Project"  in IDEA.

PS: you should run “rebuild” after you run mvn or sbt command to spark project.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值