有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何为Hadoop 2构建本机库

我已经在64位linux上安装了一个运行Hadoop 2.1测试版的集群。但是,每次运行hadoop命令工具时,都会弹出一条警告消息:

WARN util.NativeCodeLoader: Unable to load native-hadoop library for 
your platform...
using builtin-java classes where applicable

然后我发现它缺少用于64位linux的本机库。官方的hadoop 2.1 tarball仅在/lib/native文件夹中提供32位linux的本机库

我读了hadoop本机库的official document,指南上说:

Once you installed the prerequisite packages use the standard hadoop 
build.xml file and pass along the compile.native flag (set to true) to 
build the native hadoop library:

$ant -Dcompile.native=true <target>

我搜索hadoop文件夹,没有名为build.xml的文件。我没有足够的java编程和hadoop知识,所以我想知道如何为64位linux系统编译本机库?谢谢


共 (2) 个答案

  1. # 2 楼答案

    下载并安装protobuf

    wget http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz /tmp
    tar -xvf protobuf-2.5.0.tar.gz
    cd /tmp/protobuf-2.5.0
    sudo ./configure
    sudo ./make install 
    sudo ldconfig
    

    安装cmake

    sudo apt-get install cmake
    

    使用maven构建本机库

    mvn compile -Pnative
    

    如果有任何错误,请使用-e -X开关运行maven,该开关将输出详细的调试信息。查看错误是什么,并进行适当的更改

    例如,我得到了以下错误:

    [ERROR] Could not find goal 'protoc' in plugin org.apache.hadoop:hadoop-maven-plugins:3.0.0-SNAPSHOT among available goals -> [Help 1]
    

    表示您的protobuf版本不正确

    [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 "/tmp/hadoop-2.5.0-src/hadoop-common-project/hadoop-common/target/native"): error=2, No such file or directory
    

    未安装cmake

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.8.1:jar (module-javadocs) on project hadoop-annotations: MavenReportException: Error while creating archive:
    [ERROR] Exit code: 1 - /tmp/hadoop-2.5.0-src/hadoop-common-project/hadoop-annotations/src/main/java/org/apache/hadoop/classification/InterfaceStability.java:27: error: unexpected end tag: </ul>
    [ERROR] * </ul>
    

    不知道是什么问题。只需将-Dmaven.javadoc.skip=true标志传递给maven,即可跳过javadoc生成