先声明一下,本人并未安装成功,所以寻找在Mac OS 上安装Hadoop native library解决方案的就直接略过本文,免得浪费时间。
环境:
- Hadoop 1.1.1 stable with source code
- Mac OS X Mountain Lion
- GNU C compiler
- GNU Autool Chain
- zlib-dev(stable version >=1.2.0)
安装步骤:
cd $HADOOP_HOME/ && ant -Dcompile.native=true compile-native
- 第一次失败原因: [exec] configure: error: Can't find either 'objdump' or 'ldd' to compute the dynamic library for '-lz'
这是因为在Mac上没有objdump和ldd工具,但是XCode command line tools包含了一个otool可以作为替代品。Google一番后发现这个JIRA ticket: https://issues.apache.org/jira/browse/HADOOP-3659 给出了patch文件,因为这个patch文件是针对Hadoop 0.20的,所以我根据patch内容手工编辑$HADOOP_HOME/src/native/acinclude.m4,加入以下代码:
elif test ! -z "`which otool | grep -v 'no otool'`"; then ac_cv_libname_$1=\"`otool -L conftest | grep $1 | sed -e 's/^[ ]*//' -e 's/ .*//' -e 's/.*\/\(.*\)$/\1/'`\";
- 再次运行:ant -Dcompile.native=true compile-native 仍然失败,这次是: find /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/jre: No such file or directory.
修改$HADOOP_HOME/src/native/configure.ac:
原始内容:JVMSOPATH=`find $JAVA_HOME/jre/ -name 'libjvm.*' | head -n 1`
修改为: JVMSOPATH=`find $JAVA_HOME/../ -name 'libjvm.*' | head -n 1`
再次编译仍然失败:
[exec] /Users/gsun/dev/hadoop-1.1.1/src/native/src/org/apache/hadoop/security/JniBasedUnixGroupsNetgroupMapping.c:76: error: void value not ignored as it ought to be
[exec] make[1]: *** [JniBasedUnixGroupsNetgroupMapping.lo] Error 1
[exec] make: *** [all] Error 2
然后。。。就没有然后了。如果哪位大神看到本文并有解决方案请留言,不胜感激。