(4)、支持Hadoop并行数据加载。
我们可以用Kafka里面自带的脚本进行编译;我们也可以用sbt进行编译,sbt编译有点麻烦,我将在文章的后面进行介绍。
# wget http://mirror.bit.edu.cn/apache/kafka/0.8.1.1/kafka-0.8.1.1-src.tgz # tar -zxf kafka-0.8.1.1-src.tgz # cd kafka-0.8.1.1-src # ./gradlew releaseTarGz运行上面的命令进行编译将会出现以下的异常信息:
:core:signArchives FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':core:signArchives'. > Cannot perform signing task ':core:signArchives' because it has no configured signatory * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED这是一个bug(https://issues.apache.org/jira/browse/KAFKA-1297),可以用下面的命令进行编译
# git clone https://git-wip-us.apache.org/repos/asf/kafka.git # cd kafka # git checkout -b 0.8 remotes/origin/0.8 # ./sbt update [info] [SUCCESSFUL ] org.eclipse.jdt#core;3.1.1!core.jar (2243ms) [info] downloading http://repo1.maven.org/maven2/ant/ant/1.6.5/ant-1.6.5.jar ... [info] [SUCCESSFUL ] ant#ant;1.6.5!ant.jar (1150ms) [info] Done updating. [info] Resolving org.apache.hadoop#hadoop-core;0.20.2 ... [info] Done updating. [info] Resolving com.yammer.metrics#metrics-annotation;2.2.0 ... [info] Done updating. [info] Resolving com.yammer.metrics#metrics-annotation;2.2.0 ... [info] Done updating. [success] Total time: 168 s, completed Jun 18, 2014 6:51:38 PM # ./sbt package [info] Set current project to Kafka (in build file:/export1/spark/kafka/) Getting Scala 2.8.0 ... :: retrieving :: org.scala-sbt#boot-scala confs: [default] 3 artifacts copied, 0 already retrieved (14544kB/27ms) [success] Total time: 1 s, completed Jun 18, 2014 6:52:37 PM对于Kafka 0.8及以上版本还需要运行以下的命令:
# ./sbt assembly-package-dependency [info] Loading project definition from /export1/spark/kafka/project [warn] Multiple resolvers having different access mechanism configured with same name 'sbt-plugin-releases'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`). [info] Set current project to Kafka (in build file:/export1/spark/kafka/) [warn] Credentials file /home/wyp/.m2/.credentials does not exist [info] Including slf4j-api-1.7.2.jar [info] Including metrics-annotation-2.2.0.jar [info] Including scala-compiler.jar [info] Including scala-library.jar [info] Including slf4j-simple-1.6.4.jar [info] Including metrics-core-2.2.0.jar [info] Including snappy-java-1.0.4.1.jar [info] Including zookeeper-3.3.4.jar [info] Including log4j-1.2.15.jar [info] Including zkclient-0.3.jar [info] Including jopt-simple-3.2.jar [warn] Merging 'META-INF/NOTICE' with strategy 'rename' [warn] Merging 'org/xerial/snappy/native/README' with strategy 'rename' [warn] Merging 'META-INF/maven/org.xerial.snappy/snappy-java/LICENSE' with strategy 'rename' [warn] Merging 'LICENSE.txt' with strategy 'rename' [warn] Merging 'META-INF/LICENSE' with strategy 'rename' [warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard' [warn] Strategy 'discard' was applied to a file [warn] Strategy 'rename' was applied to 5 files [success] Total time: 3 s, completed Jun 18, 2014 6:53:41 PM当然,我们也可以在sbt里面指定scala的版本:
sbt "++2.10.3 update" sbt "++2.10.3 package" sbt "++2.10.3 assembly-package-dependency"