問題導讀:
1.若是獲取hadoop src maven包?
2.編譯hadoop須要裝哪些軟件?
3.如何編譯hadoop2.4?
擴展:
編譯hadoop爲什麼安裝這些軟件?
本文連接html
http://www.aboutyun.com/thread-8130-1-1.html
1、首先下載hadoop源碼包
下載的方式仍是比較多的
1.svn的方式
svn下載首先須要安裝SVN,若是想嘗試使用svn,能夠參考源碼管理、獲取網絡源碼工具:TortoiseSVN使用手冊,hadoop的svn下載地址點此
2.壓縮包的方式
這裏咱們介紹一種壓縮包的方式。
首先咱們登陸官網:
http://hadoop.apache.org/,咱們找到下面連接,點進去下載便可。若是剛接觸,不知道怎麼下載,能夠查看帖子新手指導:hadoop官網介紹及如何下載hadoop(2.4)各個版本與查看hadoop API介紹,裏面介紹的很詳細。
2、解壓
java
- aboutyun@master:~$ tar zxvf hadoop-2.4.0-src.tar.gz
解壓完畢,咱們會看到相應的文件夾:
3、解壓完畢,咱們開始準備編譯所須要的軟件
這裏軟件的準備,不少文章寫的都不全,這裏整理一下。哪些軟件是須要安裝的。linux
這裏須要說明的是有的Linux有自帶的這些工具,這個須要仔細看一下版本是否匹配,不匹配則升級一下,有些不能升級,那麼就重裝一下吧
一、jdk的安裝
步驟下載壓縮包、解壓、配置環境變量
(1)jdk下載
連接: http://pan.baidu.com/s/1jGr41SU 密碼: rawv
(2)jdk解壓apache
- tar zxvf jdk-7u51-linux-x64.tar.gz
而後重命令爲:
(3)配置環境變量:
以下圖所示紅字部分爲:(記得這裏的路徑改爲本身的實際安裝路徑)網絡
(4)檢驗是否安裝成功
二、maven的安裝
eclipse
- sudo apt-get install maven
我這裏已經安裝
上面可能還須要配置環境變量之類的,可是我這裏沒有好像是系統自帶的,網上的資料也比較多,注意maven的版本,我這裏是3.0.4,hadoop2.4須要maven的這個版本或則更高的版本3.2.1版本也是能夠的。
驗證安裝是否成功jsp
3.protobuf的安裝
(1)下載
maven
- sudo wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
(2)解壓分佈式
- tar zxvf protobuf-2.5.0.tar.gz
以下效果:
而後進入protobuf-2.5.0文件夾,進行以下操做:
svn
- $ sudo ./configure
- $ sudo make
- $ sudo make check
- $ sudo make install
- $ sudo ldconfig
(3)驗證
4.安裝openssl庫
- sudo apt-get install libssl-dev
5.CMake安裝
或則
- sudo apt-get install 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)解壓
- tar zxvf apache-ant-1.9.4-bin.tar.gz
(3)配置環境變量
以下圖所示:
1.打開profile
2.添加下圖紅字部分,記得修改爲本身的路徑
3.生效
4.檢驗
4、編譯hadoop2.4
上面準備工做已經作的差很少了,咱們終於能夠開始,記得進入src文件夾下,輸入下面命令
- mvn package -Pdist,native -DskipTests -Dtar
等了40多分鐘,ok
在目錄~/hadoop-2.4.0-src/hadoop-dist/target下有文件:
hadoop-2.4.0.tar.gz
更多內容:hadoop2.4彙總:hadoop2.4插件下載、徹底分佈式、僞分佈、eclipse插件開發大全
問題總結:
這裏還須要在補充:
1.遇到錯誤1:CMake沒有安裝
- [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: Execute failed: java.io.IOException: Cannot run program "cmake" (in
- directory "/home/wyf/hadoop-2.0.2-alpha-src/hadoop-common-project/hadoop-
- common/target/native"): java.io.IOException: error=2, No such file or directory
- -> [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
解決方法:
CMake沒有安裝
或則使用
- sudo apt-get install cmake
2.遇到錯誤2:ant沒有安裝
- ERROR] Failed to execute goal org.codehaus.mojo.jspc:jspc-maven-plugin:2.0-
- alpha-3:compile (hdfs) on project hadoop-hdfs: Execution hdfs of goal
- org.codehaus.mojo.jspc:jspc-maven-plugin:2.0-alpha-3:compile failed: Plugin
- org.codehaus.mojo.jspc:jspc-maven-plugin:2.0-alpha-3 or one of its dependencies
- could not be resolved: Could not transfer artifact ant:ant:jar:1.6.5 from/to
- central (http://repo.maven.apache.org/maven2): GET request of:
- ant/ant/1.6.5/ant-1.6.5.jar from central failed: Read timed out -> [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/PluginResolutionException
- [ERROR]
- [ERROR] After correcting the problems, you can resume the build with the command
- [ERROR] mvn <goals> -rf :hadoop-hdfs
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.解壓
- tar zxvf apache-ant-1.9.4-bin.tar.gz
3.配置環境變量
記得配置環境變量
以下圖所示:
1.打開profile
2.添加下圖紅字部分,記得修改爲本身的路徑
3.生效
4.檢驗
3.protobuf版本太低,錯誤現象
- [ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.4.0:prot
- oc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecut
- ionException: 'protoc --version' did not return a version -> [Help 1]
- [ERROR]
- [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
- ch.
- [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 rea
- d the following articles:
- [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
- xception
- [ERROR]
- [ERROR] After correcting the problems, you can resume the build with the command
- [ERROR] mvn <goals> -rf :hadoop-common
hadoop2.4對應的版本是protobuf-2.5.0
解決辦法:按照安裝步驟中protobuf的安裝便可