先记录一下我在 Mac OS X 上的解决过程: 1、 需要 JDK、Maven 环境,用 Java 的人都有 2、 需要 protobuf 这里需要注意,protobuf 的版本需要为 2.5.0 的,比如我本来用的是 proto3,就出错了
1
[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.7.1:protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionException: protoc version is 'libprotoc 3.0.0', expected version is '2.5.0' -> [Help 1]
1 2 3 4
cd protobuf-2.5.0-src ./configure --prefix=/dev/protobuf-2.5.0 make make install
将 protobuf 放进环境变量
1
export PATH=/dev/protobuf-2.5.0/bin:$PATH
验证是是否安装成功
1 2
$ protoc --version libprotoc 2.5.0
3、 下载 hadoop 对应版本的源码包,解压,然后使用 Maven 编译打包
1 2
cd hadoop-x.y.z-src mvn package -Pdist,native -DskipTests -Dtar
p.s. 如果编译过程中因为墙而无法下载到某些依赖的 jar 包,可以在 Maven 中增加一个国内的公共库
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (make) on project hadoop-common: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "cmake" (in directory "/Users/yibo/software/DevProgram/releases/hadoop-2.7.1-src/hadoop-common-project/hadoop-common/target/native"): error=2, No such file or directory
解决办法:
1
brew install cmake
②
1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (make) on project hadoop-pipes: An Ant BuildException has occured: exec returned: 1
解决办法:
1 2 3
sudo port -v selfupdate sudo port install ncurses sudo port install openssl