文档说明
该文档为完成编译后,根据印象编写,并未经过重新编译测试,大体步骤应该没错,如有错误,望指正。
编译的最初目的,是为了获取合适的native包,并且检测手动编译的native包和自带的native包有何差别。
编译的版本为apache-hadoop-2.7.6和hadoop-2.6.0-cdh5.5.0。
编译说明
源码中会有一个 BUILDING.txt 文件,编译需要的依赖和命令等大部分信息都可以在里面找到。
比如依赖:
Requirements:
* Unix System
* JDK 1.7+
* Maven 3.0 or later
* Findbugs 1.3.9 (if running findbugs)
* ProtocolBuffer 2.5.0
* CMake 2.6 or newer (if compiling native code), must be 3.0 or newer on Mac
* 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)
编译环境
$ uname -a # Linux e3base01 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ java -version # java version "1.7.0_04"
$ mvn -v # Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00)
# findbugs未安装。
$ protoc --version # libprotoc 2.5.0
$ cmake -version # cmake version 2.8.12.2
$ yum list installed | grep zlib-devel # zlib-devel.x86_64 1.2.3-29.el6 @base
$ yum list installed | grep openssl-devel # openssl-devel.x86_64 1.0.1e-57.el6 @base
$ yum list installed | grep fuse # fuse.x86_64 2.8.3-4.el6 @anaconda-CentOS-201311272149.x86_64/6.5 # 系统自带,并未刻意安装。
## 编译目录预留推荐最少5G空间,编译完后编译目录占用空间接近4G。
安装依赖
jdk
下载tar包,tar开。
配置环境变量,如~/.bash_profile中添加:
export JAVA_HOME=/path/to/jdk
export PATH=$JAVA_HOME/bin:$PATH
$ source ~/.bash_profile # 立即生效。
验证
$ java -version
maven
下载tar包,tar开。
配置环境变量,如~/.bash_profile中添加:
export MAVEN_HOME=/path/to/maven
export MAVEN_OPTS="-Xmx4g -Xms4g"
export PATH=$MAVEN_HOME/bin:$PATH
$ source ~/.bash_profile # 立即生效。
验证
$ mvn -v
protobuff
下载tar包,tar开。
# ./configure
# make
# make install
验证
$ protoc --version
cmake,zlib-devel,openssl-devel
$ yum install cmake zlib-devel openssl-devel
验证
$ yum list installed | egrep 'cmake|zlib-devel|openssl-devel'
编译命令
## 编译,并生成native。编译过程如snappy和openssl包不可用,则编译直接报错。 # 该项未测试。
$ mvn clean package -Pdist,native -Dski