背景介绍
1. 问题阐述:
在运行hadoop的时候,出现警告:
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform… using builtin-java classes where applicable
2. 原因:
Apache提供的hadoop本地库是32位的,而在64位的服务器上就会有问题,因此需要自己编译64位的版本ehe
3.验证
进入hadoop包里
cd /opt/temp/hadoop-2.2.0_32/lib/native
file libhadoop.so.1.0.0
- 若出现下面信息,则为64位
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
- 若出现下面信息,则为32位
ELF 32bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
编译前准备
1. 安装 gcc
yum install gcc
2. gcc-c++
yum install gcc-c++
这样可以避免出现问题:Cannot find appropriate C++ compiler on this system
3. JAVA
具体可参考笔者相关博文 Centos6.5 JAVA配置
4. 编译前准备其他Linux安装依赖包
yum install autoconf automake libtool cmake
yum install ncurses-devel
yum install openssl-devel
yum install lzo-devel zlib-devel
检查是否安装成功:
xxx --version
autoconf (GNU Autoconf) 2.63
automake (GNU automake) 1.11.1
ltmain.sh (GNU libtool) 2.2.6b
5. 安装maven
具体可参考笔者相关博文 Centos6.5 下 Maven 安装
6. 安装protobuf
- 下载wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz 或者去笔者我资源下下载 protobuf-2.5.0.tar.gz
- 解压压缩文件
tar -zxvf protobuf-2.5.0.tar.gz
- 进入protobuf-2.5.0目录,执行下面的命令
./configure
make
make check
make install
其中 make check
这个步骤非常耗时
- 检验
protoc --version
看能否出现libprotoc 2.5.0
信息
7. 安装cmake
- 下载 wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz 或者笔者我相关资源处 下载cmake-2.8.12.2.tar.gz