hadoop3.x源码编译及cmake的问题解决:CMake failed with error code 1
一、准备工作
基础环境:centos7
(1)官方源码中编译之前对基础环境及版本的要求(重点是红色部分)
Requirements:
* Unix System
* JDK 1.8
* Maven 3.3 or later
* ProtocolBuffer 2.5.0
* CMake 3.1 or newer (if compiling native code)
* Zlib devel (if compiling native code)
* openssl devel (if compiling native hadoop-pipes and to get the best HDFS encryption performance)
* Linux FUSE (Filesystem in Userspace) version 2.6 or above (if compiling fuse_dfs)
* Internet connection for first build (to fetch all Maven and Hadoop dependencies)
* python (for releasedocs)
* bats (for shell code testing)
* Node.js / bower / Ember-cli (for YARN UI v2 building)
(2)安装hadoop编译所需的环境依赖
1、yum install gcc gcc-c++
2、yum install autoconf automake libtool curl
3、yum install lzo-devel zlib-devel openssl openssl-devel ncurses-devel
4、yum install bzip2 bzip2-devel lzo lzo-devel lzop libXtst
5、手动安装Cmake
#yum卸载已安装cmake 版本低
yum erase cmake
#解压
tar -zxvf cmake-3.14.5.tar.gz -C /usr/local
#编译安装
cd /usr/local/cmake-3.14.5
./configure
make && make install
#验证
cmake -version
6、手动安装snappy-1.1.3
#卸载已经安装的
cd /usr/local/lib
rm -rf libsnappy*
#上传解压
tar -zxvf snappy-1.1.3.tar.gz -C /usr/local
#编译安装
cd /usr/local/snappy-1.1.3
./configure
make && make install
7、手动安装protobuf
#上传解压
tar -zxvf protobuf-2.5.0.tar.gz -C /usr/local
#编译安装
cd /usr/local/protobuf-2.5.0
./configure
make && make install
#验证
protoc -version
8、安装配置jdk1.8
#解压安装包
tar -zxvf jdk-8u191-linux-x64.tar.gz -C /usr/local
mv jdk1.8.0_191/ jdk8
#配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/jdk8
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
source /etc/profile
#验证是否安装成功
java -version
9、安装maven3.5
#解压安装包
tar -zxvf apache-maven-3.5.4-bin.tar.gz -C /usr/local
#配置环境变量
vim /etc/profile
#maven setting
export MAVEN_HOME=/usr/local/apache-maven-3.5.4
export PATH=$PATH:$MAVEN_HOME/bin
#验证
mvn -version
二、编译hadoop3.x的源码
#1、上传解压
tar -zxvf hadoop-3.1.4-src.tar.gz
#编译
cd ./hadoop-3.1.4-src
mvn clean package -Pdist,native -DskipTests -Dtar -Dbundle.snappy -Dsnappy.lib=/usr/local/lib
或者
mvn clean package -Pdist,nativeN -DskipTests -Dtar -X -Dbundle.snappy -Dsnappy.lib=/usr/local/lib
#编译成功后的hadoop压缩文件所在目录
cd ./hadoop-3.1.4-src/hadoop-dist/target
三、编译时报cmake问题:CMake failed with error code 1
解决思路:
(1)可能cmake 的版本过低导致,上述有提到,hadoop3.x依赖的cmake版本必须3.1或更高。一般手动安装应该不会有这个问题,yum安装可能会出现。
(2)在安装hadoop编译所需的依赖环境时有遗漏,我的就是因为没有执行【环境依赖】中的2、3、4步骤;直接到手动安装camke那一步了,导致一直报这个错
(3)也有可能是openssl版本问题