我目前正在一台运行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 /本地/”

什么好主意吗?


当前回答

除了@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时的警告消息应该消失。

其他回答

export HADOOP_HOME=/home/hadoop/hadoop-2.4.1  
export PATH=$HADOOP_HOME/bin:$PATH  
export HADOOP_PREFIX=$HADOOP_HOME  
export HADOOP_COMMON_HOME=$HADOOP_PREFIX  
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_PREFIX/lib/native  
export HADOOP_CONF_DIR=$HADOOP_PREFIX/etc/hadoop  
export HADOOP_HDFS_HOME=$HADOOP_PREFIX  
export HADOOP_MAPRED_HOME=$HADOOP_PREFIX  
export HADOOP_YARN_HOME=$HADOOP_PREFIX  
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH

这也是可行的:

export LD_LIBRARY_PATH=/usr/lib/hadoop/lib/native

在.bashrc文件的LD_LIBRARY_PATH中添加Hadoop本机库,并使用源~/.bashrc将库重新加载到当前会话中

export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native

(或)如果你有hadoop库安装在/usr/lib/

export LD_LIBRARY_PATH=/usr/lib/hadoop/lib/native

经过KotiI建议的持续研究,这个问题得到了解决。

hduser@ubuntu:~$ cd /usr/local/hadoop

hduser@ubuntu:/usr/local/hadoop$ ls

bin  include  libexec      logs        README.txt  share
etc  lib      LICENSE.txt  NOTICE.txt  sbin

hduser@ubuntu:/usr/local/hadoop$ cd lib

hduser@ubuntu:/usr/local/hadoop/lib$ ls
native

hduser@ubuntu:/usr/local/hadoop/lib$ cd native/

hduser@ubuntu:/usr/local/hadoop/lib/native$ ls

libhadoop.a       libhadoop.so        libhadooputils.a  libhdfs.so
libhadooppipes.a  libhadoop.so.1.0.0  libhdfs.a         libhdfs.so.0.0.0

hduser@ubuntu:/usr/local/hadoop/lib/native$ sudo mv * ../

干杯

我没有使用CentOS。以下是我在Ubuntu 16.04.2, hadoop-2.7.3, jdk1.8.0_121中的内容。运行start-dfs.sh或stop-dfs.sh成功,没有错误:

# JAVA env
#
export JAVA_HOME=/j01/sys/jdk
export JRE_HOME=/j01/sys/jdk/jre

export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:${PATH}:.

# HADOOP env
#
export HADOOP_HOME=/j01/srv/hadoop
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME

export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin

将“/j01/sys/jdk”、“/j01/srv/hadoop”替换为安装路径

我还在Ubuntu上做了以下一次设置,这样在运行start-dfs.sh时就不需要多次输入密码了:

sudo apt install openssh-server openssh-client
ssh-keygen -t rsa
ssh-copy-id user@localhost

将user替换为用户名