問題描述:
每次執行hadoop的shell命令時均出現如下警告:
[hadoop@MyDB01 ~]$ hadoop fs -ls /
16/09/25 07:59:13 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
問題定位:
用ldd命令檢視依賴庫
[hadoop@MyDB01 native]$ ldd libhadoop.so
./libhadoop.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./libhadoop.so)
linux-vdso.so.1 => (0x00007ffff3837000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fa27ce68000)
libc.so.6 => /lib64/libc.so.6 (0x00007fa27cad3000)
/lib64/ld-linux-x86-64.so.2 (0x000000333de00000)
[hadoop@MyDB01 native]$ ldd libhadoop.so.1.0.0
./libhadoop.so.1.0.0: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./libhadoop.so.1.0.0)
linux-vdso.so.1 => (0x00007fff4b9ff000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2a22745000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2a223b0000)
/lib64/ld-linux-x86-64.so.2 (0x000000333de00000)
[hadoop@MyDB01 native]$
看到報錯,GLIBC_2.14找不到,現在檢查系統的glibc庫, ldd --version即可檢查:
[hadoop@MyDB01 native]$ ldd --version
ldd (GNU libc) 2.12
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
由 Roland McGrath 和 Ulrich Drepper 編寫。
[hadoop@MyDB01 native]$
原來系統預裝的glibc庫是2.12版本,而hadoop期望是2.14版本,所以列印警告資訊。
解決方案:
第一個辦法重新編譯glibc重新編譯glibc.2.14版本,安裝後專門給hadoop使用,這個有點危險。
第二個辦法直接在log4j日誌中去除告警資訊。在//usr/local/hadoop/etc/hadoop/log4j.properties檔案中新增
log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR
參考:http://blog.csdn.net/l1028386804/article/details/51538611
如何檢視識別hadoop是32位還是64位:hadoop-2.6.0
[hadoop@MyDB01 native]$ pwd
/usr/local/hadoop/lib/native
[hadoop@MyDB01 native]$ ls
libhadoop.a libhadoop.so libhadooputils.a libhdfs.so
libhadooppipes.a libhadoop.so.1.0.0 libhdfs.a libhdfs.so.0.0.0
[hadoop@MyDB01 native]$ file libhadoop.so.1.0.0
libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
[hadoop@MyDB01 native]$