mac环境编译hadoop源码
准备:
1.源码下载,版本hadoop-2.2.0
svn co https://svn.apache.org/repos/asf/hadoop/common/tags/release-2.2.0/
由于Hadoop本地库只支持*nix平台,已经广泛使用在GNU/Linux平台上,但是不支持 Cygwin 和 Mac OS X 。在MAC上编译需求进行适当的修改
wget https://issues.apache.org/jira/secure/attachment/12617363/HADOOP-9648.v2.patch patch -p1 < HADOOP-9648.v2.patch
2.libprotoc 2.5.0
3.cmake version 3.3.2
4.编译:
mvn package -Pdist,native -DskipTests -Dtar
4.1)会报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common: An Ant BuildException has occured: exec returned: 1
原因是由于maven国外服务器可能连不上,先给maven配置一下国内镜像,在maven目录下,conf/settings.xml
在<mirrors></mirros>里添加,原本的不要动 <mirror> <id>nexus-osc</id> <mirrorOf>*</mirrorOf> <name>Nexusosc</name> <url>http://maven.oschina.net/content/groups/public/</url> </mirror> 在<profiles></profiles>内新添加 <profile> <id>jdk-1.7</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile>
4.2)failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.0:site (default-site) on project
解决方案:http://dougchang333.blogspot.com/2013/11/hadoop-build-error-javalangnoclassdeffo.html
pom.xml里有两处都要修改,不要漏了。
4.3)Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common:
可能zlib和findbugs没安装
4.4)mac下zlib安装
$ brew install zlib Error: No available formula for zlib Searching formulae... lzlib Searching taps... homebrew/dupes/zlib
出现这个问题时,先执行以下命令
$ brew untap homebrew/dupes $ brew tap homebrew/dupes 再执行 $ brew install zlib
安装后需要将zlib的头文件及库文件添加至系统默认的路径
#ln -s /usr/local/Cellar/zlib/1.2.8/include/* /usr/local/include #ln -s /usr/local/Cellar/zlib/1.2.8/lib/* /usr/local/lib
参考文献:
1.安装http://blog.csdn.net/u014227228/article/details/28248755
2.编译错误http://m.blog.csdn.net/blog/xinsuixiaofeiyu/38439195