错误: 找不到或无法加载主类 Djava.library.path=.usr.hadoop.hadoop-2.8.0.lib:.
答案:1 悬赏:70 手机版
解决时间 2021-02-27 17:47
- 提问者网友:十年饮冰
- 2021-02-27 03:01
错误: 找不到或无法加载主类 Djava.library.path=.usr.hadoop.hadoop-2.8.0.lib:.
最佳答案
- 五星知识达人网友:第幾種人
- 2021-02-27 04:38
最近,打算Hbase建表用snappy压缩时,碰到一些Hadoop本地库的问题。其实这些问题是一直存在的,只是不影响正常使用,就没有引起重视。这次希望彻底解决以下问题:
问题一:执行start-dfs.sh时出现以下日志
xxxx: Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/hadoop-2.4.0/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
xxxx: It's highly recommended that you fix the library with 'execstack -c', or link it with '-z noexecstack'.
这是因为官网提供的版本本地库是32位的,在64位主机环境下无法执行。需要下载hadoop源码进行编译(如何编译源码可以上网搜索),编译成功后,找到native下的文件拷贝到${HADOOP_HOME}/lib/native目录下即可。
问题二:执行start-dfs.sh时出现以下日志
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
在网上找到的所有文章中,都是说在hadoop-env.sh中加入以下两行配置:
export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_HOME}/lib/native
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/"
但是在测试过程中,加入以上配置还是会提示告警信息,说明本地库未加载成功。
开启debug:
export HADOOP_ROOT_LOGGER=DEBUG,console
执行start-dfs.sh,发现以下日志:
DEBUG util.NativeCodeLoader: Failed to load native-hadoop with error: Java.lang.UnsatisfiedLinkError: no hadoop in java.library.path
从日志中可以看出hadoop库不在java.library.path所配置的目录下,应该是java.library.path配置的路径有问题。在hadoop-env.sh中重新配置:
export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_HOME}/lib/native
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native/"
执行start-dfs.sh,告警信息不再显示。经测试,其实只需export HADOOP_OPTS即可解决问题。
验证本地库是否加载成功:hadoop checknative
15/08/18 10:31:17 INFO bzip2.Bzip2Factory: Successfully loaded & initialized native-bzip2 library system-native
15/08/18 10:31:17 INFO zlib.ZlibFactory: Successfully loaded & initialized native-zlib library
Native library checking:
hadoop: true /usr/local/hadoop-2.4.0/lib/native/libhadoop.so.1.0.0
zlib: true /lib64/libz.so.1
snappy: true /usr/local/hadoop-2.4.0/lib/native/Linux-amd64-64/libsnappy.so.1
lz4: true revision:99
bzip2: true /lib64/libbz2.so.1
以上说明本地库已经加载成功。
问题一:执行start-dfs.sh时出现以下日志
xxxx: Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/hadoop-2.4.0/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
xxxx: It's highly recommended that you fix the library with 'execstack -c
这是因为官网提供的版本本地库是32位的,在64位主机环境下无法执行。需要下载hadoop源码进行编译(如何编译源码可以上网搜索),编译成功后,找到native下的文件拷贝到${HADOOP_HOME}/lib/native目录下即可。
问题二:执行start-dfs.sh时出现以下日志
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
在网上找到的所有文章中,都是说在hadoop-env.sh中加入以下两行配置:
export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_HOME}/lib/native
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/"
但是在测试过程中,加入以上配置还是会提示告警信息,说明本地库未加载成功。
开启debug:
export HADOOP_ROOT_LOGGER=DEBUG,console
执行start-dfs.sh,发现以下日志:
DEBUG util.NativeCodeLoader: Failed to load native-hadoop with error: Java.lang.UnsatisfiedLinkError: no hadoop in java.library.path
从日志中可以看出hadoop库不在java.library.path所配置的目录下,应该是java.library.path配置的路径有问题。在hadoop-env.sh中重新配置:
export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_HOME}/lib/native
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native/"
执行start-dfs.sh,告警信息不再显示。经测试,其实只需export HADOOP_OPTS即可解决问题。
验证本地库是否加载成功:hadoop checknative
15/08/18 10:31:17 INFO bzip2.Bzip2Factory: Successfully loaded & initialized native-bzip2 library system-native
15/08/18 10:31:17 INFO zlib.ZlibFactory: Successfully loaded & initialized native-zlib library
Native library checking:
hadoop: true /usr/local/hadoop-2.4.0/lib/native/libhadoop.so.1.0.0
zlib: true /lib64/libz.so.1
snappy: true /usr/local/hadoop-2.4.0/lib/native/Linux-amd64-64/libsnappy.so.1
lz4: true revision:99
bzip2: true /lib64/libbz2.so.1
以上说明本地库已经加载成功。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯