WARN : Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
搜索的结果大部分说是操作系统与hadoop的位数不一致造成的,然而事实并非如此。
本文的操作系统为centos 64位,而也是64位的
$ file ../lib/native/.1.0.0
../lib/native/.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
后来甚至在机器上耗费数天从编译hadoop到编译spark,最后依然会提示上述warning,那么显然问题并不是位数冲突造成的了。
由于上述warning并不能提供更多有效的信息,需要增加debug信息:
export HADOOP_ROOT_LOGGER=DEBUG,console
再次执行./,这次debug到一些有用的信息:
16/07/05 15:33:54 DEBUG : setsid exited with exit code 0
16/07/05 15:33:54 DEBUG : field . $ with annotation @.(value=[Rate of successful kerberos logins and latency (milliseconds)], about=, valueName=Time, type=DEFAULT, always=false, sampleName=Ops)
16/07/05 15:33:54 DEBUG : field . $ with annotation @.(value=[Rate of failed kerberos logins and latency (milliseconds)], about=, valueName=Time, type=DEFAULT, always=false, sampleName=Ops)
16/07/05 15:33:54 DEBUG : field . $ with annotation @.(value=[GetGroups], about=, valueName=Time, type=DEFAULT, always=false, sampleName=Ops)
16/07/05 15:33:54 DEBUG : UgiMetrics, User and group related metrics
16/07/05 15:33:55 DEBUG : Creating new Groups object
16/07/05 15:33:55 DEBUG : Trying to load the custom-built native-hadoop library...
<span style="color:#FF0000;">16/07/05 15:33:55 DEBUG : Failed to load native-hadoop with error: : no hadoop in
16/07/05 15:33:55 DEBUG : =/usr/local/sinasrv2/hadoop/hadoop-2.6.4/lib
16/07/05 15:33:55 WARN : Unable to load native-hadoop library for your platform... using builtin-java classes where applicable</span>
16/07/05 15:33:55 DEBUG : Falling back to shell based
16/07/05 15:33:55 DEBUG : Group mapping impl=
16/07/05 15:33:55 DEBUG : Group mapping impl=; cacheTimeout=300000; warningDeltaMs=5000
16/07/05 15:33:55 DEBUG : hadoop login
16/07/05 15:33:55 DEBUG : hadoop login commit
16/07/05 15:33:55 DEBUG : using local user:UnixPrincipal: hadoop
16/07/05 15:33:55 DEBUG : Using user: "UnixPrincipal: hadoop" with name hadoop
16/07/05 15:33:55 DEBUG : User entry: "hadoop"
16/07/05 15:33:55 DEBUG : UGI loginUser:hadoop (auth:SIMPLE)
16/07/05 15:33:55 DEBUG : PrivilegedAction as:hadoop (auth:SIMPLE) from:(:314)
可以看到是上述标红位置出现了问题。也就是从处没有找到,我们发现,是存放在/usr/local/sinasrv2/hadoop/hadoop-2.6.4/lib/native下的
在hadoop包中搜索发现,被定义为$JAVA_LIBRARY_PATH
$ grep -R '' *
bin/yarn: YARN_OPTS="$YARN_OPTS -=$JAVA_LIBRARY_PATH"
bin/: set YARN_OPTS=%YARN_OPTS% -=%JAVA_LIBRARY_PATH%
etc/hadoop/: YARN_OPTS="$YARN_OPTS -=$JAVA_LIBRARY_PATH"
etc/hadoop/: set YARN_OPTS=%YARN_OPTS% -=%JAVA_LIBRARY_PATH%
libexec/:# setup '' for native-hadoop code if necessary
libexec/: HADOOP_OPTS="$HADOOP_OPTS -=$JAVA_LIBRARY_PATH"
libexec/:@rem setup '' for native hadoop code if necessary
libexec/: set HADOOP_OPTS=%HADOOP_OPTS% -=%JAVA_LIBRARY_PATH%
share/doc/hadoop/common/: HADOOP-8756. Fix SEGV when libsnappy is in but
share/doc/hadoop/common/: HADOOP-1660. Add the cwd of the map/reduce task to the
share/doc/hadoop/common/: 50. HADOOP-1493. Permit specification of "" system
share/doc/hadoop/common/:10. HADOOP-873. Pass correctly to child processes.
share/doc/hadoop/common/:42. HADOOP-838. Fix tasktracker to pass to
share/doc/hadoop/mapreduce/: MAPREDUCE-4458. Warn if is used for AM or Task
share/doc/hadoop/mapreduce/: MAPREDUCE-4072. User set seems to overwrite default
share/doc/hadoop/mapreduce/: MAPREDUCE-3259. Added of NodeManager to
但是此时发现环境变量$JAVA_LIBRARY_PATH并未定义,那么问题到这里终于算是找到了,解决方法也很简单了,vim /etc/profile,添加$JAVA_LIBRARY_PATH环境变量
export JAVA_LIBRARY_PATH='/usr/local/sinasrv2/hadoop/hadoop-2.6.4/lib/native'
source /etc/profile 使之生效
再执行,则不会出现上述warning信息
2、在执行spark-shell的时候出现上述warning信息
同样的思路,修改spark的日志级别为warning,vim $SPARK_HOME/conf/
=WARNING, console
得到如下错误信息:
16/07/06 12:15:41 DEBUG Groups: Creating new Groups object
16/07/06 12:15:41 DEBUG NativeCodeLoader: Trying to load the custom-built native-hadoop library...
16/07/06 12:15:41 DEBUG NativeCodeLoader: Failed to load native-hadoop with error: : no hadoop in
16/07/06 12:15:41 DEBUG NativeCodeLoader: =/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
16/07/06 12:15:41 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
16/07/06 12:15:41 DEBUG PerformanceAdvisory: Falling back to shell based
又是的问题,Orz…
但是在grep的时候,没有发现的出处,也不知道其值是如何设定的。问题虽然找到了,但是解决方法一筹莫展。只要求助万能的度娘了…
这篇帖子也是同样的问题,/topics/390978577,采用7楼的解决方法:
在spark的conf目录下,修改文件加入LD_LIBRARY_PATH环境变量,值为hadoop的native库的路径
果然凑效!
vim $SPARK_HOME/conf/
export SPARK_MASTER_IP=hadoop1
export SPARK_MASTER_PORT=7077
export SPARK_WORKER_CORES=1
export SPARK_WORKER_INSTANCES=1
export SPARK_WORKER_MEMORY=512M
export LD_LIBRARY_PATH=$JAVA_LIBRARY_PATH