問題導讀:
1.若是獲取hadoop src maven包?
2.編譯hadoop須要裝哪些軟件?
3.如何編譯hadoop2.4?
擴展:
編譯hadoop爲什麼安裝這些軟件?
1、首先下載hadoop源碼包
下載的方式仍是比較多的
1.svn的方式
svn下載首先須要安裝SVN,若是想嘗試使用svn,能夠參考源碼管理、獲取網絡源碼工具:TortoiseSVN使用手冊,hadoop的svn下載地址點此
2.壓縮包的方式
這裏咱們介紹一種壓縮包的方式。
首先咱們登陸官網:
http://hadoop.apache.org/,咱們找到下面連接,點進去下載便可。若是剛接觸,不知道怎麼下載,能夠查看帖子新手指導:hadoop官網介紹及如何下載hadoop(2.4)各個版本與查看hadoop API介紹,裏面介紹的很詳細。
2、解壓
html
解壓完畢,咱們會看到相應的文件夾:java
3、解壓完畢,咱們開始準備編譯所須要的軟件
這裏軟件的準備,不少文章寫的都不全,這裏整理一下。哪些軟件是須要安裝的。linux
這裏須要說明的是有的Linux有自帶的這些工具,這個須要仔細看一下版本是否匹配,不匹配則升級一下,有些不能升級,那麼就重裝一下吧
一、jdk的安裝
步驟下載壓縮包、解壓、配置環境變量
(1)jdk下載
連接: http://pan.baidu.com/s/1jGr41SU 密碼: rawv
(2)jdk解壓shell
而後重命令爲:
(3)配置環境變量:
以下圖所示紅字部分爲:(記得這裏的路徑改爲本身的實際安裝路徑)apache
(4)檢驗是否安裝成功
二、maven的安裝
ubuntu
我這裏已經安裝
上面可能還須要配置環境變量之類的,可是我這裏沒有好像是系統自帶的,網上的資料也比較多,注意maven的版本,我這裏是3.0.4,hadoop2.4須要maven的這個版本或則更高的版本3.2.1版本也是能夠的。
驗證安裝是否成功bash
3.protobuf的安裝
爲防止出錯,這裏補充一些內容,
3.1先安裝g++網絡
(1)下載eclipse
因爲google不能訪問,能夠從網盤下載連接:http://pan.baidu.com/s/1dDgWe6P 密碼:xgiu
(2)解壓jsp
以下效果:
>
而後進入protobuf-2.5.0文件夾,進行以下操做:
修改環境變量:
(LD_LIBRARY_PATH的這裏,填寫的是protobuf文件的位置)
注意:配置/etc/profile,在虛擬機重啓後,可能配置會失效,因此重啓後,須要再次執行source操做。
(3)驗證
4.安裝openssl庫
5.CMake安裝
或則
6.ant安裝
(1)首先下載ant
百度網盤: apache-ant-1.9.4-bin.tar.gz
http://pan.baidu.com/s/1c0vjhBy
或則下面連接:
apache-ant-1.9.4-bin.tar.gz
(2)解壓
(3)配置環境變量
以下圖所示:
1.打開profile
2.添加下圖紅字部分,記得修改爲本身的路徑
3.生效
4.檢驗
4、編譯hadoop2.4
上面準備工做已經作的差很少了,咱們終於能夠開始,記得進入src文件夾下,輸入下面命令
等了40多分鐘,ok
在目錄~/hadoop-2.4.0-src/hadoop-dist/target下有文件:
hadoop-2.4.0.tar.gz
更多內容:hadoop2.4彙總:hadoop2.4插件下載、徹底分佈式、僞分佈、eclipse插件開發大全
問題總結:
這裏還須要在補充:
1.遇到錯誤1:CMake沒有安裝
解決方法:
CMake沒有安裝
或則使用
2.遇到錯誤2:ant沒有安裝
1.首先下載ant
百度網盤: apache-ant-1.9.4-bin.tar.gz
http://pan.baidu.com/s/1c0vjhBy
或則下面連接:
apache-ant-1.9.4-bin.tar.gz
2.解壓
3.配置環境變量
記得配置環境變量
以下圖所示:
1.打開profile
2.添加下圖紅字部分,記得修改爲本身的路徑
3.生效
4.檢驗
3.protobuf版本太低,錯誤現象
hadoop2.4對應的版本是protobuf-2.5.0
解決辦法:按照安裝步驟中protobuf的安裝便可
4.權限問題
解決辦法:
(1)加上sudo
(2)經過
安裝包解壓以後,所屬用戶可能發生變化:
改變用戶
sudo chown -R aboutyun:aboutyun hadoop-2.4.0-src
上面aboutyun改爲本身的所屬組和用戶
命令查看是否屬於當前用戶
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common: An Ant BuildException has occured: exec returned: 1 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. 安裝zlib-devel ubuntu安裝是 sudo apt-get install zlib1g-dev
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (make) on project hadoop-pipes: An Ant BuildException has occured: exec returned: 1 [ERROR] around Ant part ...<exec dir="/home/xxl/hadoop-2.5.2-src/hadoop-tools/hadoop-pipes/target/native" executable="cmake" failonerror="true">... @ 5:120 in /home/xxl/hadoop-2.5.2-src/hadoop-tools/hadoop-pipes/target/antrun/build-main.xml [ERROR] -> [Help 1]
安裝:sudo apt-get install libssl-dev
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (tar) on project hadoop-dist: An Ant BuildException has occured: exec returned: 1 [ERROR] around Ant part ...<exec dir="/home/xxl/hadoop-2.5.2-src/hadoop-dist/target" executable="sh" failonerror="true">... @ 21:96 in /home/xxl/hadoop-2.5.2-src/hadoop-dist/target/antrun/build-main.xml
安裝:sudo apt-get install build-essential
sudo apt-get install libglib2.0-dev
錯誤信息:
1
2
3
4
5
6
7
8
9
10
|
[ERROR] Failed to execute goal on project hadoop-auth: Could not resolve dependencies
for
project org.apache.hadoop:hadoop-auth:jar:2.2.0: Could not transfer artifact org.mortbay.jetty:jetty:jar:6.1.26 from
/to
central (https:
//repo
.maven.apache.org
/maven2
): GET request of: org
/mortbay/jetty/jetty/6
.1.26
/jetty-6
.1.26.jar from central failed: SSL peer shut down incorrectly -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to
enable
full debug logging.
[ERROR]
[ERROR] For
more
information about the errors and possible solutions, please
read
the following articles:
[ERROR] [Help 1] http:
//cwiki
.apache.org
/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the
command
[ERROR] mvn -rf :hadoop-auth
|
解決辦法:
這是hadoop的一個bug,在pom.xml中添加下面patch便可,詳見https://issues.apache.org/jira/browse/HADOOP-10110 。
編輯`hadoop-common-project/hadoop-auth/pom.xml`文件:
1
|
vi hadoop-common-project/hadoop-auth/pom.xml
|
在<dependencys></dependencys>
節點中插入:
1
2
3
4
5
|
<
dependency
>
<
groupId
>org.mortbay.jetty</
groupId
>
<
artifactId
>jetty-util</
artifactId
>
<
scope
>test</
scope
>
</
dependency
>
|
錯誤信息:
1
2
3
4
5
6
7
8
9
10
|
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (
make
) on project hadoop-pipes: An Ant BuildException has occured:
exec
returned: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to
enable
full debug logging.
[ERROR]
[ERROR] For
more
information about the errors and possible solutions, please
read
the following articles:
[ERROR] [Help 1] http:
//cwiki
.apache.org
/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the
command
[ERROR] mvn -rf :hadoop-pipes
|
解決辦法:
1
|
apt-get
install
libssl-dev
|