欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

安装Hadoop时Unable to load native-hadoop library for your platform报错原因

程序员文章站 2022-07-06 09:38:08
...

刚安装完hadoop后,出现了如下报错

[[email protected] ~]# /usr/local/hadoop/sbin/start-dfs.sh
20/06/04 08:22:37 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [localhost]
localhost: namenode running as process 19541. Stop it first.
localhost: datanode running as process 19667. Stop it first.
Starting secondary namenodes [0.0.0.0]
0.0.0.0: secondarynamenode running as process 19839. Stop it first.
20/06/04 08:22:40 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

意思是:WARN级别的警告,无法为平台加载本地hadoop库…可使用合适的内置java类。

这个时候使用jps指令可以检查NameNode和DateNode是否正常启动。

[[email protected] ~]# jps
19667 DataNode
19541 NameNode
19097 Jps
19839 SecondaryNameNode

可能的原因:
Apache提供的hadoop本地库是32位的,而在64位的服务器上就会有问题,因此需要自己编译64位的版本。
解决方法
1、首先找到对应自己hadoop版本的64位的lib包,可以自己手动去编译
2、可以上网下载对应的编译版本
(如http://dl.bintray.com/sequenceiq/sequenceiq-bin/)
将准备好的64位的lib包解压到已经安装好的hadoop安装目录的lib/native 和 lib目录下

[[email protected] ~]# tar -xvf hadoop-native-64-2.7.0.tar -C /usr/local/hadoop/lib/native

[[email protected] ~]# tar -xvf hadoop-native-64-2.7.0.tar -C /usr/local/hadoop/lib

添加环境变量

[[email protected] ~]# vim /etc/profile
在/etc/profile中添加以下内容
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
 
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"

让环境变量生效

[[email protected] ~]# source /etc/profile 

再尝试一次/usr/local/hadoop/sbin/start-dfs.sh

[[email protected] native]# /usr/local/hadoop/sbin/start-dfs.sh
Starting namenodes on [localhost]
localhost: namenode running as process 19541. Stop it first.
localhost: datanode running as process 19667. Stop it first.
Starting secondary namenodes [0.0.0.0]
0.0.0.0: secondarynamenode running as process 19839. Stop it first.

没有报错了

hadoop安装参考https://www.cnblogs.com/StarZhai/p/11712074.html