编译hadoop2.7

系统要求

* 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)

我是在root下操作的 如果您是其他用户 请在适当时间配置好sudo并使用sudo命令

安装jdk

就是解压缩然后配下path路径,网上有很多相关文章,但是最好卸载掉其他的jdk,

只留下oracle的jdk

tar -zxvf jdk-7u71-linux-x64.tar.gz
配置环境变量:vi /etc/profile

export JAVA_HOME= 你的安装路径

export PATH=.:$PATH:$JAVA_HOME/bin

安装maven

同样解压缩配置 /etc/profile

export MAVEN_HOME=你的安装路径
export PATH=.:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
同样,输入命令使配置文件生效  
source /etc/profile
检测是否安装成功:mvn  -version

安装protobuf  
protobuf请提前下载

安装前请安装
yum  install  gcc  
yum  install  gcc-c++
yum install  make 
安装protobuf,解压缩
tar -zxvf protobuf-2.5.0.tar.gz
然后进入到安装目录中,以此输入一下命令: 
cd protobuf-2.5.0
./configure
make(这一步时间比较长)
make  install

安装CMake
CMake 需要2.6以上的版本需要联网

yum  install  cmake    
yum  install  openssl-devel
yum  install  ncurses-devel

补充一点在编译请把maven仓库配置成阿里云的

在maven的settings.xml 文件里配置mirrors的子节点,添加如下mirror

<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror> 

安装ant

tar -zxvf apache-ant-1.9.7-bin.tar.gz

配置环境变量
vi /etc/profile
export ANT_HOME=你的路径
export PATH=.:$PATH:$ANT_HOME/bin

生效以及测试
source /etc/profile
ant  -version

编译hadoop
解压hadoop源码包
tar -zxvf hadoop-2.5.2-src.tar.gz
进入文件夹里面,里面有一个文件BUILDINT.txt
在BUILDING.txt这层目录里,输入命令
mvn package -Pdist,native -DskipTests -Dtar
或者mvn  package -DeskipTests -Pdist,native
编译
完成后会有提示



 编译出的jar在

 [exec] Hadoop dist tar available at: /export/software/hadoop-2.7.4-src/hadoop-dist/target/hadoop-2.7.4.tar.gz

ok了祝你愉快,如有不明欢迎留言

猜你喜欢

转载自java-doom.iteye.com/blog/2403707