環境說明
centos6.4 64bit
更新系統安裝包
yum update
安裝
yum -y install svn git ncurses-devel gcc* lzo-devel zlib-devel autoconf automake libtool cmake openssl-devel
安裝protobuf
centos6.4用yum安裝是2.3.0,得用最新的,就編譯安裝
安裝jdk,ant,maven
修改maven的配置conf/settings.xml,強烈建議做這一步,國外的鏡像很不穩定,有時候會下載下傳失敗導緻編譯失敗,這時候得重新編譯n(n>=1)次才能通過,改用國内的鏡像之後,下載下傳速度特别快,整個編譯過程也提速不少。
一是在 之間添加
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexusosc</name>
<url</url>
</mirror>
二是在之間添加
<profile>
<id>jdk-1.7</id>
<activation>
<jdk>1.7</jdk>
</activation>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url/url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url></url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
安裝findbugs
解壓,設定環境變量就行
安裝forrest
也是解壓,設定環境變量就行。(我沒裝這個也編譯成功了)
8.2.2.0裡邊有個bug,需要在在hadoop-common-project/hadoop-auth/pom.xml中添加幾行代碼
在之間添加
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<scope>test</scope>
</dependency>
看了下2.4.1裡邊已經把這個bug修複了。
編譯
有人說用root使用者編譯會出錯,沒試,我用普通使用者編譯的,都沒sudo權限。在hadoop-src目錄下執行,編譯所用使用者需要對此目錄擁有寫權限,這一點很重要,編譯時會産生大量的中間檔案和結果檔案,沒有寫權限就會報錯。
mvn clean package -Pdist,native -DskipTests -Dtar
如果想檢視更詳細的資訊,可以加上-X -e,将輸出級别調到debug級别。
改了鏡像之後下載下傳jar包很快,比編譯2.2.0時(當時沒改)速度快很多,在伺服器上編譯的,用了23分鐘。
編譯之後
遇到的錯誤
http://stackoverflow.com/questions/20381070/ant-buildexception-error-building-hadoop-2-2-0
http://stackoverflow.com/questions/17126213/building-hadoop-with-maven-failed-to-execute-goal-org-apache-maven-pluginsma