Hadoop 2.6.1 Warning: WARN util.NativeCodeLoader

被刻印的时光 ゝ 提交于 2019-12-04 18:48:35

I had same problem. Fortunately the problem has been solved. You can see the solution below.

A few times displaying the warning does not let you upload a file to HDFS. So when there is no warning, there is no such problem.

Open the hadoop-env.sh and go to the end of the file and try to add the following lines

export HADOOP_HOME_WARN_SUPPRESS=1
export HADOOP_ROOT_LOGGER="WARN,DRFA"

I had the same problem and resolved it by adding following xml files in job configuration.

Configuration conf = job.getConfiguration();

//To access HDFS files
conf.addResource(new Path(hadoopHome+"/conf/core-site.xml"));//In my case hadoopHome is /usr/lib/hadoop
conf.addResource(new Path(hadoopHome+"/conf/hdfs-site.xml"));

conf.addResource(new Path(hadoopHome+"/conf/mapred-site.xml")); //To run a mapreduce job

/* Other configurations comes here*/

One reason for the warning can be that there is processor architecture conflict (32 vs 64 bit). Another could be that the native library is not on the java library path (or a library it needs is not on the path).

Executing the following should give you more detailed information:

hadoop checknative -a

Also shouldn't your HADOOP_OPTS actually point to the lib directory instead of lib/native ?

Maybe you should add the following to your log4j.properties file to get more info: log4j.logger.org.apache.hadoop.util.NativeCodeLoader=DEBUG

There are also a few other things you can try:

1)

suda hadoop checknative -a

(to check whether it's a permission issue)

2) Setting the LD_LIBRARY_PATH additionally.

I built hadoop-3.0.0-SNAPSHOT from source with support for native code, adjusted the environment variable HADOOP_COMMON_LIB_NATIVE_DIR:

HADOOP_COMMON_LIB_NATIVE_DIR=/Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/lib/native.

Now, both versions of hadoop (e.g. 2.3.0 and 3.0 SNAPSHOT) get no warning:

HADOOP_HOME=/Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT
HADOOP_COMMON_LIB_NATIVE_DIR=/Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/lib/native
HADOOP_INSTALL=/Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT
HADOOP_CONF_DIR=/Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/etc/hadoop
HADOOP_OPTS=-Djava.library.path=/Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/lib/native


$ hadoop version
Hadoop 2.3.0
Subversion http://svn.apache.org/repos/asf/hadoop/common -r 1567123
Compiled by jenkins on 2014-02-11T13:40Z
Compiled with protoc 2.5.0
From source with checksum dfe46336fbc6a044bc124392ec06b85
This command was run using /Users/davidlaxer/hadoop-2.3.0/share/hadoop/common/hadoop-common-2.3.0.jar

$ bin/hadoop version
Hadoop 3.0.0-SNAPSHOT
Source code repository https://github.com/apache/hadoop.git -r 83e65c5fe84819b6c6da015b269fb4e46a88d105
Compiled by davidlaxer on 2015-09-26T22:46Z
Compiled with protoc 2.5.0
From source with checksum 883bd12016a9bbe21eb0ae4b6beaa
This command was run using /Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/share/hadoop/common/hadoop-common-3.0.0-SNAPSHOT.jar

$ bin/hadoop fs -ls /users/davidlaxer/genomics/reads/HG00103
Found 1 items
drwxr-xr-x   - davidlaxer staff        102 2015-09-26 09:13 /users/davidlaxer/genomics/reads/HG00103/_temporary
David-Laxers-MacBook-Pro:hadoop-3.0.0-SNAPSHOT davidlaxer$ bin/hadoop version
Hadoop 3.0.0-SNAPSHOT
Source code repository https://github.com/apache/hadoop.git -r 83e65c5fe84819b6c6da015b269fb4e46a88d105
Compiled by davidlaxer on 2015-09-26T22:46Z
Compiled with protoc 2.5.0
From source with checksum 883bd12016a9bbe21eb0ae4b6beaa
This command was run using /Users/davidlaxer/hadoop/hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/share/hadoop/common/hadoop-common-3.0.0-SNAPSHOT.jar
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!