我目前正在一台运行CentOs的服务器上配置hadoop。当我运行start-dfs.sh或stop-dfs.sh时,我得到以下错误:
警告跑龙套。NativeCodeLoader:无法加载原生hadoop库
你的平台……在适用的地方使用内置java类
我运行的是Hadoop 2.2.0。
我在网上搜索了一下,找到了这个链接:http://balanceandbreath.blogspot.ca/2013/01/utilnativecodeloader-unable-to-load.html
但是,hadoop 2上的/native/目录的内容。x似乎不同,所以我不知道该怎么办。
我还在hadoop-env.sh中添加了以下两个环境变量:
出口HADOOP_OPTS = " HADOOP_OPTS美元
-Djava.library.path = / usr /地方/ hadoop / lib /”
出口HADOOP_COMMON_LIB_NATIVE_DIR = " / usr /地方/ hadoop / lib /本地/”
什么好主意吗?
从以前的帖子验证补救措施:
1)检查Hadoop发行版附带的libhadoop.so.1.0.0是否为我的机器架构编译,即x86_64:
[nova]:file /opt/hadoop-2.6.0/lib/native/libhadoop.so.1.0.0
/opt/hadoop-2.6.0/lib/native/libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=3a80422c78d708c9a1666c1a8edd23676ed77dbb, not stripped
2)添加-Djava.library。path=<path hadoop-env.sh中的> to HADOOP_OPT:
export HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true -Djava.library.path=/opt/hadoop-2.6.0/lib/native"
这确实使恼人的警告消失了。
除了@zhutoulala接受的答案之外,这里是一个更新,使其能够在ARMHF平台(树莓派3模型B)上使用最新的稳定版本(2.8)。
首先,我可以确认您必须将本机库重新编译为64位ARM,这里基于设置一些环境变量的其他答案将不起作用。正如Hadoop文档中所指出的,预构建的本机库是32位的。
第一个链接(http://www.ercoppa.org/posts/how-to-compile-apache-hadoop-on-ubuntu-linux.html)中给出的高级步骤是正确的。
在这个网址http://www.instructables.com/id/Native-Hadoop-260-Build-on-Pi/上,你可以获得更多关于树莓派的详细信息,但不包括Hadoop 2.8版。
以下是我对Hadoop 2.8的建议:
there is still no protobuf package on latest Raspbian so you must compile it yourself and version must be exactly protobuf 2.5 (https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz)
CMake file patching method must be changed. Moreovere, files to patch are not the same. Unfortunately, there is no accepted patch on JIRA specific to 2.8. On this URL (https://issues.apache.org/jira/browse/HADOOP-9320) you must copy and paste Andreas Muttscheller proposed patch on your namenode :
:hadoop-2.8.0-src/hadoop-common-project/hadoop-common $ touch HADOOP-9320-v2.8.patch
:hadoop-2.8.0-src/hadoop-common-project/hadoop-common $ vim HADOOP-9320-v2.8.patch
#copy and paste proposed patch given here : https://issues.apache.org/jira/browse/HADOOP-9320?focusedCommentId=16018862&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16018862
:hadoop-2.8.0-src/hadoop-common-project/hadoop-common $ patch < HADOOP-9320-v2.8.patch
patching file HadoopCommon.cmake
patching file HadoopJNI.cmake
:hadoop-2.8.0-src/hadoop-common-project/hadoop-common $ cd ../..
:hadoop-2.8.0-src $ sudo mvn package -Pdist,native -DskipTests -Dtar
一旦构建成功:
:hadoop-2.8.0-src/hadoop-dist/target/hadoop-2.8.0/lib/native $ tar -cvf nativelibs.tar *
用这个归档文件的内容替换Hadoop安装的lib/native目录的内容。运行Hadoop时的警告消息应该消失。