如何为Hadoop2构建本机库

mcdcgff0  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(356)

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

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

然后我发现它缺少用于64位linux的本机库。官方的hadoop2.1tarball只提供了32位linux的本机库 /lib/native 文件夹。
我读了hadoop本机库的官方文档,指南上说:

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系统编译本机库?谢谢。

r7knjye2

r7knjye21#

构建系统已更改为maven。您可以在此处找到构建说明:https://svn.apache.org/repos/asf/hadoop/common/trunk/building.txt
具体来说,您可以运行以下命令:mvn package-pdist、native、docs-dskiptests-dtar
(安装protobuf 2.5.0后)

gopyfrb3

gopyfrb32#

下载并安装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

如果有任何错误,请运行maven -e -X 输出详细调试信息的开关。查看错误是什么,并进行适当的更改。
例如,我得到以下错误:

[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。

相关问题