目錄 正文 下載Hadoop源碼
1、登錄官網(wǎng)


2、確定你要安裝的軟件的版本
一個(gè)選取原則: 不新不舊的穩(wěn)定版本
幾個(gè)標(biāo)準(zhǔn):
1)一般來說,剛剛發(fā)布的大版本都是有很多問題
2)應(yīng)該選擇某個(gè)大版本中的最后一個(gè)小版本
閱讀編譯文檔
1、準(zhǔn)備一個(gè)hadoop源碼包,我選擇的hadoop的版本是:hadoop-2.7.5-src.tar.gz,在hadoop-2.7.5-src.tar.gz的源碼包根目錄下有一個(gè)文檔叫做BUINDING.txt,這其中說明了編譯hadoop所需要的一些編譯環(huán)境相關(guān)的東西。不同的hadoop版本的要求都不一樣。對(duì)應(yīng)的版本參照BUINDING.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)
軟件安裝
對(duì)應(yīng)以上需求,我們準(zhǔn)備好所要求版本的這些軟件。
JDK的安裝
選擇版本:jdk1.8.0_73
安裝依賴包
根據(jù)編譯指導(dǎo)文件BUILDING.txt,安裝相關(guān)依賴程序包
[root@master soft]# yum -y install gcc-c++ build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-devua svn openssl-devel ncurses-devel

View Code

安裝Maven
編譯要求:Maven 3.0 or later 安裝軟件:apache-maven-3.0.5-bin.tar.gz
1 2 3 4 | [root@hadoop1 soft]# ls
apache-maven-3.3.9-bin.tar.gz
[root@hadoop1 soft]# chmod 755 apache-maven-3.3.9-bin.tar.gz
[root@hadoop1 soft]# tar -zxvf apache-maven-3.3.9-bin.tar.gz <br>。。。<br>[root@hadoop1 soft]# mv apache-maven-3.3.9 /opt/<br>[root@hadoop1 soft]# vi /etc/profile
|


配置mvn的環(huán)境變量
export M2_HOME=/opt/apache-maven-3.3. export PATH=$PATH:$M2_HOME/bin
測(cè)試
[root@hadoop1 soft]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /opt/apache-maven-3.3.9
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: /usr/local/jdk1.8.0_73/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.el6.x86_64", arch: "amd64", family: "unix"
[root@hadoop1 soft]#

安裝Findbugs
編譯要求:Findbugs 1.3.9 安裝軟件:findbugs-3.0.1.tar.gz
[root@hadoop1 soft]# ls
findbugs-3.0.1.tar.gz
[root@hadoop1 soft]# chmod 755 findbugs-3.0.1.tar.gz
[root@hadoop1 soft]# tar -zxvf findbugs-3.0.1.tar.gz -C /opt
配置Findbugs環(huán)境變量
[root@hadoop1 soft]# vi /etc/profile
export FINDBUGS_HOME=/opt/findbugs-3.0.1 export PATH=$PATH:$FINDBUGS_HOME/bin

測(cè)試
[root@hadoop1 soft]# findbugs -version
3.0.1
[root@hadoop1 soft]#

安裝ProtocolBuffer
編譯要求:ProtocolBuffer 2.5.0 安裝軟件:protobuf-2.5.0.tar.gz,不建議用其它版本
[root@hadoop1 soft]# ls
protobuf-2.5.0.tar.gz
[root@hadoop1 soft]# chmod 755 protobuf-2.5.0.tar.gz
[root@hadoop1 soft]# tar -zxvf protobuf-2.5.0.tar.gz -C /opt [root@hadoop1 soft]# cd /opt/protobuf-2.5.0/ [root@hadoop1 protobuf-2.5.0]# ./configure [root@hadoop1 protobuf-2.5.0]# make [root@hadoop1 protobuf-2.5.0]# make install
測(cè)試
[root@hadoop1 protobuf-2.5.0]# protoc --version
libprotoc 2.5.0
[root@hadoop1 protobuf-2.5.0]#

修改maven的配置文件,添加maven的下載源
[root@hadoop1 protobuf-2.5.0]# cd /opt/apache-maven-3.3.9/conf/ [root@hadoop1 conf]# vi settings.xml
在mirrors中添加alimaven的下載源
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
安裝Ant
[root@hadoop1 soft]# ls
apache-ant-1.9.4-bin.tar.gz hadoop-2.7.5-src
[root@hadoop1 soft]# tar -zxvf apache-ant-1.9.4-bin.tar.gz -C /opt/
配置環(huán)境變量
[root@hadoop1 apache-ant-1.9.4]# vi /etc/profile
#Ant
export ANT_HOME=/opt/apache-ant-1.9.4
export PATH=$PATH:$ANT_HOME/bin
檢測(cè)
[root@hadoop1 apache-ant-1.9.4]# ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
[root@hadoop1 apache-ant-1.9.4]#

安裝Snappy
解壓
[root@hadoop1 soft]# ls
hadoop-2.7.5-src snappy-1.1.1.tar.gz
[root@hadoop1 soft]# tar -zxvf snappy-1.1.1.tar.gz -C /opt/
安裝
[root@hadoop1 soft]# cd /opt/snappy-1.1.1/
[root@hadoop1 snappy-1.1.1]# ./configure
[root@hadoop1 snappy-1.1.1]# make
[root@hadoop1 snappy-1.1.1]# make install
查看snappy文件庫(kù)
[root@hadoop1 snappy-1.1.1]# ls -lh /usr/local/lib | grep snappy
-rw-r--r-- 1 root root 228K 3月 3 09:51 libsnappy.a
-rwxr-xr-x 1 root root 953 3月 3 09:51 libsnappy.la
lrwxrwxrwx 1 root root 18 3月 3 09:51 libsnappy.so -> libsnappy.so.1.2.0
lrwxrwxrwx 1 root root 18 3月 3 09:51 libsnappy.so.1 -> libsnappy.so.1.2.0
-rwxr-xr-x 1 root root 145K 3月 3 09:51 libsnappy.so.1.2.0
[root@hadoop1 snappy-1.1.1]#
開始編譯hadoop
[root@hadoop1 soft]# ls
[root@hadoop1 soft]# tar -zxvf hadoop-2.7.5-src.tar.gz
在編譯之前防止java.lang.OutOfMemoryError:Java heap space堆棧問題,在centos系統(tǒng)中執(zhí)行命令
[root@hadoop1 snappy-1.1.1]# export MAVEN_OPTS="-Xms256m -Xmx512m"
進(jìn)入源碼包下,執(zhí)行命令進(jìn)行編譯
[root@hadoop1 snappy-1.1.1]# cd /soft/hadoop-2.7.5-src/
[root@hadoop1 hadoop-2.7.5-src]# mvn package -Pdist,native,docs -DskipTests -Dtar
如果中途編譯失敗,并且不要文檔的話,請(qǐng)使用這個(gè)命令:
[root@master ~]# mvn clear package -Pdist,native -DskipTests -Dtar -Dsnappy.lib=/usr/local/lib -Dbundle.snappy -Drequire.openssl

編譯成功之后,hadoop-2.7.5.tar.gz位于/soft/hadoop-2.7.5-src/hadoop-dist/target目錄下,這是編譯后文件夾的狀態(tài)

至此,大功告成!??!
|