Original source: http://blog.csdn.net/hgd250/article/details/8697547
需要注意的是 hadoop2.0.3 alpha的編譯,必須使用protobuf2.4.1. 使用 2.4.0,2.5.0均會失敗。
1.安裝JDK、Maven並設置環境變量
a) JDK安裝配置過程省略
b) Maven安裝配置過程
下載地址:http://labs.mop.com/apache-mirror/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
解壓即可,並設置MAVEN_HOME,將$MAVEN_HOME/bin 加入PATH
設置本地倉庫路徑:$MAVEN_HOME/conf/setting.xml
< localRepository >/runtu/repo</ localRepository > |
代理上網的話需要設置:$MAVEN_HOME/conf/setting.xml
< proxies > < proxy > < id >optional</ id > < active >true</ active > < protocol >http</ protocol > < host >192.168.0.1</ host > < port >80</ port > < nonProxyHosts >local.net|some.host.com</ nonProxyHosts > </ proxy > </ proxies > |
2.安裝protobuf
下載地址:http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.4.1.tar.gz&can=2&q=
安裝過程:
tar zxvf protobuf-2.4.1. tar .gz cd protobuf-2.4.1 . /configure make make check make install |
查看是否安裝成功:protoc --version 3.下載Hadooop源碼。 源碼包地址:http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.0.3-alpha/hadoop-2.0.3-alpha-src.tar.gz Svn:http://svn.apache.org/repos/asf/hadoop/common/tags/release-2.0.3-alpha/ 4.源碼編譯腳本:
Create binary distribution without native code and without documentation: $ mvn package -Pdist -DskipTests -Dtar Create binary distribution with native code and with documentation: $ mvn package -Pdist,native,docs -DskipTests -Dtar Create source distribution: $ mvn package -Psrc -DskipTests Create source and binary distributions with native code and documentation: $ mvn package -Pdist,native,docs,src -DskipTests -Dtar Create a local staging version of the website ( in /tmp/hadoop-site ) $ mvn clean site; mvn site:stage -DstagingDirectory= /tmp/hadoop-site |
注意:
使用代理上網增加配置: -Dhttp.proxyHost=192.168.0.1 -Dhttp.proxyPort=80
如: $ mvn package -Pdist -DskipTests -Dtar -Dhttp.proxyHost=192.168.0.1
-Dhttp.proxyPort=80