@sasaki
2016-05-12T15:56:12.000000Z
字数 11056
阅读 3664
BigData
Hadoop
@Title MAC环境编译Hadoop 2.6
@Version v1.0
@Timestamp 2016-05-12 19:44
@Author Nicholas
@Mail redskirt@outlook.com
硬件环境:MacBook Pro Retina
软件环境:
解压hadoop-2.6.0-src.tar.gz
至需要的路径,执行mvn编译
Nicholas-MacBook-Pro:hadoop-2.6.0-src sasaki$ mvn install -DskipTests
在进行到hadoop-common子项目时遇到如下异常:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.192 s
[INFO] Finished at: 2016-05-12T09:51:44+08:00
[INFO] Final Memory: 58M/284M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.6.0:protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version -> [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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :hadoop-common
异常信息说描述得很清楚,当前环境缺少protocbuf组件,protobuf是GitHub一个很火的开源项目。
解决
下载protocol buffer工具:
https://developers.google.com/protocol-buffers/docs/downloads#latest-version
(链接地址需要梯子,你懂的)
Nicholas-MacBook-Pro:Downloads sasaki$ tar -zxvf protobuf-2.5.0.tar.gz
# 解压并进入protobuf目录
Nicholas-MacBook-Pro:Downloads sasaki$ cd protobuf-2.5.0
Nicholas-MacBook-Pro:~ sasaki$ ls /opt/protobuf-2.5.0/
CHANGES.txt config.log ltmain.sh
CONTRIBUTORS.txt config.status m4
COPYING.txt config.sub missing
INSTALL.txt configure protobuf-lite.pc
Makefile configure.ac protobuf-lite.pc.in
Makefile.am depcomp protobuf.pc
Makefile.in editors protobuf.pc.in
README.txt examples python
aclocal.m4 generate_descriptor_proto.sh src
autogen.sh gtest stamp-h1
config.guess install-sh vsprojects
config.h java
config.h.in libtool
# 终端切换管理员
Nicholas-MacBook-Pro:protobuf-2.6.1 sasaki$ sudo su
Password:
sh-3.2# ./configure --prefix=/usr/local/protobuf
...
sh-3.2# make check
...过程比较漫长
...
make[6]: Nothing to be done for `all-am`.
============================================================================
Testsuite summary for Protocol Buffers 2.6.1
============================================================================
# TOTAL: 5
# PASS: 5
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
# 执行编译
sh-3.2# make install
# 检票是否安装成功
sh-3.2# protoc --version
libprotoc 2.5.0
# 添加到路径
sh-3.2# ./configure --prefix=/usr
安装完protoc后再次执行编译,遇到如下异常
Exception in thread "main" java.lang.AssertionError: Missing tools.jar at: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/Classes/classes.jar. Expression: file.exists()
at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:395)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:683)
at org.codehaus.mojo.jspc.CompilationMojoSupport.findToolsJar(CompilationMojoSupport.groovy:371)
at org.codehaus.mojo.jspc.CompilationMojoSupport.this$4$findToolsJar(CompilationMojoSupport.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrent0(ScriptBytecodeAdapter.java:112)
at org.codehaus.mojo.jspc.CompilationMojoSupport.execute(CompilationMojoSupport.groovy:318)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
报错说在/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/Classes
目录下没有classes.jar文件,但是我尝试进入该目录发现并没有../Classes/
目录,结合上下文说缺失tools.jar
文件,tools.jar
本身是jdk安装目录自带的一个jar,但这里却说该目录没有,无奈Google之,发现解决方式很简单。
解决
找到$JAVA_HOME$/lib
目录下的tools.jar
,复制到报错的目录并重命名为classes.jar
文件即可。
Nicholas-MacBook-Pro:Classes sasaki$ pwd
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/Classes
Nicholas-MacBook-Pro:Classes sasaki$ sudo ln -s ../lib/tools.jar classes.jar
Nicholas-MacBook-Pro:Classes sasaki$ ls
classes.jar
再次执行编译,一路顺畅,编译完成。
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Hadoop Main ................................. SUCCESS [ 2.021 s]
[INFO] Apache Hadoop Project POM .......................... SUCCESS [ 0.984 s]
[INFO] Apache Hadoop Annotations .......................... SUCCESS [ 1.269 s]
[INFO] Apache Hadoop Project Dist POM ..................... SUCCESS [ 0.898 s]
[INFO] Apache Hadoop Assemblies ........................... SUCCESS [ 0.352 s]
[INFO] Apache Hadoop Maven Plugins ........................ SUCCESS [ 3.099 s]
[INFO] Apache Hadoop MiniKDC .............................. SUCCESS [ 0.976 s]
[INFO] Apache Hadoop Auth ................................. SUCCESS [ 1.403 s]
[INFO] Apache Hadoop Auth Examples ........................ SUCCESS [ 1.706 s]
[INFO] Apache Hadoop Common ............................... SUCCESS [ 17.642 s]
[INFO] Apache Hadoop NFS .................................. SUCCESS [ 0.344 s]
[INFO] Apache Hadoop KMS .................................. SUCCESS [ 2.618 s]
[INFO] Apache Hadoop Common Project ....................... SUCCESS [ 0.041 s]
[INFO] Apache Hadoop HDFS ................................. SUCCESS [ 40.273 s]
[INFO] Apache Hadoop HttpFS ............................... SUCCESS [ 3.332 s]
[INFO] Apache Hadoop HDFS BookKeeper Journal .............. SUCCESS [ 1.027 s]
[INFO] Apache Hadoop HDFS-NFS ............................. SUCCESS [ 0.803 s]
[INFO] Apache Hadoop HDFS Project ......................... SUCCESS [ 0.056 s]
[INFO] hadoop-yarn ........................................ SUCCESS [ 0.082 s]
[INFO] hadoop-yarn-api .................................... SUCCESS [ 3.896 s]
[INFO] hadoop-yarn-common ................................. SUCCESS [ 4.698 s]
[INFO] hadoop-yarn-server ................................. SUCCESS [ 0.038 s]
[INFO] hadoop-yarn-server-common .......................... SUCCESS [ 1.289 s]
[INFO] hadoop-yarn-server-nodemanager ..................... SUCCESS [ 2.358 s]
[INFO] hadoop-yarn-server-web-proxy ....................... SUCCESS [ 0.730 s]
[INFO] hadoop-yarn-server-applicationhistoryservice ....... SUCCESS [ 1.390 s]
[INFO] hadoop-yarn-server-resourcemanager ................. SUCCESS [ 3.952 s]
[INFO] hadoop-yarn-server-tests ........................... SUCCESS [ 0.893 s]
[INFO] hadoop-yarn-client ................................. SUCCESS [ 1.084 s]
[INFO] hadoop-yarn-applications ........................... SUCCESS [ 0.055 s]
[INFO] hadoop-yarn-applications-distributedshell .......... SUCCESS [ 0.749 s]
[INFO] hadoop-yarn-applications-unmanaged-am-launcher ..... SUCCESS [ 0.494 s]
[INFO] hadoop-yarn-site ................................... SUCCESS [ 0.054 s]
[INFO] hadoop-yarn-registry ............................... SUCCESS [ 1.142 s]
[INFO] hadoop-yarn-project ................................ SUCCESS [ 0.230 s]
[INFO] hadoop-mapreduce-client ............................ SUCCESS [ 0.151 s]
[INFO] hadoop-mapreduce-client-core ....................... SUCCESS [ 3.719 s]
[INFO] hadoop-mapreduce-client-common ..................... SUCCESS [ 1.926 s]
[INFO] hadoop-mapreduce-client-shuffle .................... SUCCESS [ 0.686 s]
[INFO] hadoop-mapreduce-client-app ........................ SUCCESS [ 2.048 s]
[INFO] hadoop-mapreduce-client-hs ......................... SUCCESS [ 1.281 s]
[INFO] hadoop-mapreduce-client-jobclient .................. SUCCESS [ 2.564 s]
[INFO] hadoop-mapreduce-client-hs-plugins ................. SUCCESS [ 0.440 s]
[INFO] Apache Hadoop MapReduce Examples ................... SUCCESS [ 0.902 s]
[INFO] hadoop-mapreduce ................................... SUCCESS [ 0.144 s]
[INFO] Apache Hadoop MapReduce Streaming .................. SUCCESS [ 0.916 s]
[INFO] Apache Hadoop Distributed Copy ..................... SUCCESS [ 23.791 s]
[INFO] Apache Hadoop Archives ............................. SUCCESS [ 0.668 s]
[INFO] Apache Hadoop Rumen ................................ SUCCESS [ 1.217 s]
[INFO] Apache Hadoop Gridmix .............................. SUCCESS [ 1.033 s]
[INFO] Apache Hadoop Data Join ............................ SUCCESS [ 0.565 s]
[INFO] Apache Hadoop Ant Tasks ............................ SUCCESS [ 0.334 s]
[INFO] Apache Hadoop Extras ............................... SUCCESS [ 0.714 s]
[INFO] Apache Hadoop Pipes ................................ SUCCESS [ 0.055 s]
[INFO] Apache Hadoop OpenStack support .................... SUCCESS [ 0.869 s]
[INFO] Apache Hadoop Amazon Web Services support .......... SUCCESS [ 3.328 s]
[INFO] Apache Hadoop Client ............................... SUCCESS [ 0.629 s]
[INFO] Apache Hadoop Mini-Cluster ......................... SUCCESS [ 0.235 s]
[INFO] Apache Hadoop Scheduler Load Simulator ............. SUCCESS [ 0.883 s]
[INFO] Apache Hadoop Tools Dist ........................... SUCCESS [ 0.621 s]
[INFO] Apache Hadoop Tools ................................ SUCCESS [ 0.058 s]
[INFO] Apache Hadoop Distribution ......................... SUCCESS [ 0.209 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:36 min
[INFO] Finished at: 2016-05-12T14:54:57+08:00
[INFO] Final Memory: 182M/546M
[INFO] ------------------------------------------------------------------------