YARN加载本地库抛出Unable to load native

用官方的Hadoop 2.1.0-beta安装后,每次hadoop命令进去都会抛出这样一个Warning

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

设置logger级别,看下具体原因

export HADOOP_ROOT_LOGGER=DEBUG,console​

13/08/29 13:59:38 DEBUG util.NativeCodeLoader: Trying to load the custom-built native-hadoop library...
13/08/29 13:59:38 DEBUG util.NativeCodeLoader: Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: /usr/local/hadoop/hadoop-2.1.0-beta/lib/native/libhadoop.so.1.0.0: /usr/local/hadoop/hadoop-2.1.0-beta/lib/native/libhadoop.so.1.0.0: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
13/08/29 13:59:38 DEBUG util.NativeCodeLoader: java.library.path=/usr/local/hadoop/hadoop-2.1.0-beta/lib/native/Linux-amd64-64:/usr/local/hadoop/hadoop-2.1.0-beta/lib/native
13/08/29 13:59:38 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicablewrong ELFCLASS32,难道是加载的so文件系统版本不对

执行命令file libhadoop.so.1.0.0

libhadoop.so.1.0.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

果然是80386,是32位的系统版本,而我的hadoop环境是64位OS
原来直接从apache镜像中下载的编译好的Hadoop版本native library都是32版本的,如果要支持64位版本,必须自己重新编译,这就有点坑爹了,要知道几乎所有的生产环境都是64位的OS
YARN官方对于native library的一段话验证了这一点
“The pre-built 32-bit i386-Linux native hadoop library is available as part of the hadoop distribution and is located in the lib/native directory​”


重新checkout source code
svn checkout
加上编译native的选项,编译时会根据当前的操作系统架构来生产相应的native库
mvn package -Pdist,native -DskipTests -Dtar
再去native文件下查看所有的file type,已经都是64位版的了,替换线上文件,WARNING消除
file *
libhadoop.a:        current ar archive
libhadooppipes.a:  current ar archive
libhadoop.so:      symbolic link to `libhadoop.so.1.0.0'
libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, not stripped
libhadooputils.a:  current ar archive
libhdfs.a:          current ar archive
libhdfs.so:        symbolic link to `libhdfs.so.0.0.0'
libhdfs.so.0.0.0:  ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, not stripped

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d59932ddd4282cb379114047afd3734d.html