这里面选择的HADOOP的版本为2.6.编译前需要准备的如下工具:


    HADOOP:   hadoop-2.6.0-src.tar.gz

    JDK:   jdk-7u71-linux-x64.tar.gz

    MAVEN:  apache-maven-3.0.5-bin.tar.gz

    PROTOBUF:   protobuf-2.5.0.tar.gz

    FINDBUGS:    findbugs-3.0.0.tar.gz

    ANT:  apache-ant-1.9.4-bin.tar.gz 

1、分别解压hadoop、JDK、MAVEN PROTOBUF FINDBUGS  ANT。这里以/app为根目录:

 tar -zxvf  hadoop-2.6.0-src.tar.gz

 tar -zxvf    jdk-7u71-linux-x64.tar.gz

 tar -zxvf   apache-maven-3.0.5-bin.tar.gz

 tar -zxvf   protobuf-2.5.0.tar.gz

 tar -zxvf    findbugs-3.0.0.tar.gz

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

对解压后的JDK 、ANT、PROTOBUF 、FINDBUGS重命名:

mv jdk-7u71-linux-x64   jdk7

mv protobuf-2.5.0  protobuf

mv findbugs-3.0.0  findbugs 

mv apache-ant-1.9.4 ant 

2、配置环境变量

           export JAVA_HOME=/app/jdk7

export MAVEN_HOME=/app/apache-maven-3.0.5

export ANT_HOME=/app/ant

export FINDBUGS_HOME=/app/findbugs

export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=.:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$MAVEN_HOME/bin:$ANT_HOME/bin:$FINDBUGS_HOME/bin:$PATH:$CLASSPATH

3、分别验证安装是否成功:

    java -version

java version "1.7.0_71"

Java(TM) SE Runtime Environment (build 1.7.0_71-b14)

Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

            

    mvn -version

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:28+0800)

Maven home: /app/apache-maven-3.0.5

Java version: 1.7.0_71, vendor: Oracle Corporation

Java home: /app/jdk7/jre

Default locale: zh_CN, platform encoding: UTF-8

OS name: "linux", version: "2.6.32-431.el6.x86_64", arch: "amd64", family: "unix"


    ant -version

        Apache Ant(TM) version 1.9.4 compiled on April 29 2014


     findbugs -version

        3.0.0


如果出现上面的提示,说明 安装成功

4、安装 protobuf所有依赖:

           yum install gcc

yum intall gcc-c++

yum install make

yum install cmake

yum install openssl-devel

yum install ncurses-devel


5、安装protobuf-2.5.0.tar.gz

     cd /app/profobuf 目录中执行如下登命令:

./configure 

make

make check

make install

    验证:

         protoc --version

              libprotoc 2.5.0

6、编译HADOOP:

    cd /app/hadoop-2.6.0-src   

    在该目录中用如下命令:


        mvn clean install -DskipTests   

           mvn package -DskipTests -Pdist ,native ,docs -Dtar 或者
        mvn package -Pdist,native -DskipTests -Dtar

    由于这里面没有配置MAVEN镜象地址所以下载比较慢。接下来就是等了。

7、查看编译完的文件:

    cd /app/hadoop-2.6.0-src/hadoop-dist/target/hadoop-2.6.0/lib/native  

     用如下命令:

        file *

    显示如下已经编译成功:

libhadoop.a:        current ar archive

libhadooppipes.a:   current ar archive

libhadoop.so:       symbolic link to `libhadoop.so.1.0.0'

libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped

libhadooputils.a:   current ar archive

libhdfs.a:          current ar archive

libhdfs.so:         symbolic link to `libhdfs.so.0.0.0'

libhdfs.so.0.0.0:   ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped