hadoop2.4 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
在Ubuntu上安装完hadoop2.4以后,使用以下命令:
hadoop fs -ls 14/09/09 11:33:51 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Found 1 items drwxr-xr-x - duomai supergroup 0 2014-09-05 12:10 flume
有个WARN提示hadoop不能加载本地库,网上搜了下,这个问题基本上是由于在apache hadoop官网上下载的hadoopXXX.bin.tar.gz实在32位的机器上编译的(蛋疼吧),我集群使用的64bit的,加载.so文件时出错,当然基本上不影响使用hadoop(如果你使用mahout做一些机器学习的任务时有可能会遇到麻烦,加载不成功,任务直接退出,所以还是有必要解决掉这个warn的)。
但是每次运行一个命令多有这么个WARN很不爽,想干掉也很简单:
1. 下载hadoop2.4源码 2. 在集群的某台机器上编译 3. 替换之前的$HADOOP_HOME/lib/native为新编译的native
其中有几点注意的:
(1)在2(进行编译)之前,先修改maven安装目录下conf/settings.xml(因为maven使用的国外的reposity,国内有时无法访问,修改为国内镜像即可),<mirrors></mirros>里添加,其他的不需改动,具体修改如下:
<mirror> <id>nexus-osc</id> <mirrorOf>*</mirrorOf> <name>Nexusosc</name> <url>http://maven.oschina.net/content/groups/public/</url> </mirror>
同样,在<profiles></profiles>内新添加
<profile> <id>jdk-1.7</id> <activation> <jdk>1.7</jdk> </activation> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile>
修改完成后使用以下命令编译hadoop;
mvn package -Dmaven.javadoc.skip=true -Pdist,native -DskipTests -Dtar
然后就是等待,大概20min后,build success,目标在
hadoop-2.4.1-src/hadoop-dist/target/hadoop-2.4.1.tar.gz
(2)在编译成功后,将新的lib/native替换到集群中原来的lib/native,记得要修改$HADOOP_HOME/etc/hadoop/hadoop-env.sh,在最后加上;
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib:$HADOOP_HOME/lib/native"
======
重新运行如下命令:
hadoop fs -ls Found 1 items drwxr-xr-x - duomai supergroup 0 2014-09-05 12:10 flume
WARN消失,good!
参考资料:
1. http://hadoop.apache.org/docs/r2.4.0/hadoop-project-dist/hadoop-common/NativeLibraries.html
2. http://stackoverflow.com/questions/19943766/hadoop-unable-to-load-native-hadoop-library-for-your-platform-error-on-centos
3. http://blog.csdn.net/w13770269691/article/details/16883663/#