hadoop2.7.1本地编译

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 )
* Jansson C XML parsing library ( if compiling libwebhdfs )
* 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)

1、设置的环境变量如下:

export JAVA_HOME=/opt/jdk
export ANT_HOME=/opt/soft/apache-ant-1.9.6
export MAVEN_HOME=/opt/soft/maven
export MAVEN_OPTS="-Xms256m -Xmx512m"
export FINDBUGS_HOME=/opt/soft/findbugs-2.0.2
export JRE_HOME=/opt/jdk/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:/opt/soft/sbt/bin:$MAVEN_HOME/bin:$FINDBUGS_HOME/bin:$ANT_HOME/bin:$PATH

2、yum  -y install build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev

3、解压protobuf-2.5.0.tar.gz   然后安装 1)./configure  2)   make    3) make install

4、进入到hadoop-2.7.1-src目录,执行mvn package -Pdist,native,docs -DskipTests -Dtar

如果要支持snappy,应该这样 :

mvn package -Pdist,native,docs -DskipTests -Dtar -Drequire.snappy -Dbundle.snappy -Dsnappy.lib=/usr/local/lib

前提是要先按照snappy lib库到/usr/local/lib下:

下载:http://pkgs.fedoraproject.org/repo/pkgs/snappy/snappy-1.1.1.tar.gz/8887e3b7253b22a31f5486bca3cbc1c2/snappy-1.1.1.tar.gz

$sudo ./configure$ sudo make$ sudo make install

这样就支持snappy压缩了,在2.0里,snappy的jar文件已经在common里自带了,至少我知道在2.5已经有了。

接下来就是漫长的等待,有些包下载的会比较慢,如果一些包下载过慢甚至最后停止,下次再重新编译的时候一定要先mvn clean 。我就遇到了下面的问题:

[ERROR] around Ant part ...<exec dir="/opt/soft/hadoop-2.7.1-src/hadoop-hdfs-project/hadoop-hdfs-httpfs/target" executable="sh" failonerror="true">... @ 10:123 in /opt/soft/hadoop-2.7.1-src/hadoop-hdfs-project/hadoop-hdfs-httpfs/target/antrun/build-main.xml
[ERROR] -> [Help 1]

主要原因是:../hadoop-2.7.1-src/hadoop-hdfs-project/hadoop-hdfs-httpfs/downloads/apache-tomcat-6.0.41.tar.gz 这个文件没下载完整,可以手工下载放到这,也可以删除重新下载。

遇到这个问题,要先看ant文件,最后知道是下载tomcat失败,文件过小,没下载完整。如果不把这个没下载的小文件删除,永远会失败下去。

另外,对这个编译要有耐心。祝你成功!!!


你可能感兴趣的:(hadoop2.7.1本地编译)