hadoop 2.x安装:不能加载本地库 - java.library.path错误
我们在启动hadoop2.x是可能会有下面这个警告:
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
这个警告实际上就是不能加载本地库。因为这个错误的原因有很多,因此这里给出一种方案
1. 在hadoop-env.sh中加入DEBUG
现在我们无从判定问题在哪里,因此我们在tiny1(master)的hadoop-env.sh中加入DEBUG,即在该文件下加入这一行:
export HADOOP_ROOT_LOGGER=DEBUG,console
2.重启hadoop查看日志输出
17/03/09 18:49:14 DEBUG util.NativeCodeLoader: Trying to load the custom-built native-hadoop library...
17/03/09 18:49:14 DEBUG util.NativeCodeLoader: Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: no hadoop in java.library.path
17/03/09 18:49:14 DEBUG util.NativeCodeLoader: java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
17/03/09 18:49:14 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
日志中显示他的 java.library.path是hadoop-2.7.2/lib,但是他的实际位置是hadoop-2.7.2/lib/native
3.修改hadoop-env.sh解决当前问题
添加:
export HADOOP_COMMON_LIB_NATIVE_DIR=/home/hadoop/hadoop/hadoop-2.7.2/lib/native
修改
export HADOOP_OPTS="-Djava.library.path=/home/hadoop/hadoop/hadoop-2.7.2/lib/native"
至此我们在hadoop-env.sh中的三个添加或修改的配置文件如下:
export HADOOP_COMMON_LIB_NATIVE_DIR=/home/hadoop/hadoop/hadoop-2.7.2/lib/native
export HADOOP_OPTS="-Djava.library.path=/home/hadoop/hadoop/hadoop-2.7.2/lib/native"
export HADOOP_ROOT_LOGGER=DEBUG,console
4.重启hadoop
我们关闭hadoop并重新开启hadoop
hadoop/hadoop-2.7.2/sbin/stop-all.sh
hadoop/hadoop-2.7.2/sbin/start-all.sh
我们查看日志:
17/03/09 19:11:22 DEBUG util.NativeCodeLoader: Trying to load the custom-built native-hadoop library...
17/03/09 19:11:22 DEBUG util.NativeCodeLoader: Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: /home/hadoop/hadoop/hadoop-2.7.2/lib/native/libhadoop.so.1.0.0: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/hadoop/hadoop/hadoop-2.7.2/lib/native/libhadoop.so.1.0.0)
17/03/09 19:11:22 DEBUG util.NativeCodeLoader: java.library.path=/home/hadoop/hadoop/hadoop-2.7.2/lib/native
17/03/09 19:11:22 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
还是有错...错误信息为version `GLIBC_2.14' not found,我们在另外一篇中解决