標籤:style http io color ar os 使用 java sp
在http://www.aboutyun.com/thread-8130-1-1.html 這裡看到到,安裝過程遇到了上面說的問題,所以將此文轉載過來,以備不時之需,感謝此作者。
問題導讀:
1.如果擷取hadoop src maven包?
2.編譯hadoop需要裝哪些軟體?
3.如何編譯hadoop2.4?
擴充:
編譯hadoop為何安裝這些軟體?
一、首先下載hadoop源碼包
下載的方式還是比較多的
1.svn的方式
svn下載首先需要安裝SVN,如果想嘗試使用svn,可以參考源碼管理、擷取網路源碼工具:TortoiseSVN使用手冊,hadoop的svn點此
2.壓縮包的方式
這裡我們介紹一種壓縮包的方式。
首先我們登入官網:
http://hadoop.apache.org/,我們找到下面連結,點進去下載即可。如果剛接觸,不知道怎麼下載,可以查看文章新手指導:hadoop官網介紹及如何下載hadoop(2.4)各個版本與查看hadoop API介紹,裡面介紹的很詳細。
二、解壓
- [email protected]:~$ tar zxvf hadoop-2.4.0-src.tar.gz
複製代碼
解壓完畢,我們會看到相應的檔案夾:
三、解壓完畢,我們開始準備編譯所需要的軟體
這裡軟體的準備,很多文章寫的都不全,這裡整理一下。哪些軟體是需要安裝的。
這裡需要說明的是有的Linux有內建的這些工具,這個需要仔細看一下版本是否匹配,不匹配則升級一下,有些不能升級,那麼就重裝一下吧
1、jdk的安裝
步驟下載壓縮包、解壓、配置環境變數
(1)jdk下載
連結: http://pan.baidu.com/s/1jGr41SU 密碼: rawv
(2)jdk解壓
- tar zxvf jdk-7u51-linux-x64.tar.gz
複製代碼
然後重命令為:
(3)配置環境變數:
如所示紅字部分為:(記得這裡的路徑改成自己的實際安裝路徑)
- /usr/jdk1.7/bin
複製代碼
(4)檢驗是否安裝成功
2、maven的安裝
- sudo apt-get install maven
複製代碼
我這裡已經安裝
上面可能還需要配置環境變數之類的,但是我這裡沒有好像是系統內建的,網上的資料也比較多,注意maven的版本,我這裡是3.0.4,hadoop2.4需要maven的這個版本或則更高的版本3.2.1版本也是可以的。
驗證安裝是否成功
- mvn -version
複製代碼
3.protobuf的安裝
為防止出錯,這裡補充一些內容,
3.1先安裝g++
- sudo apt-get install g++
複製代碼
(1)下載
- sudo wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
複製代碼
由於google不能訪問,可以從網盤下載連結:http://pan.baidu.com/s/1dDgWe6P 密碼:xgiu
(2)解壓
- tar zxvf protobuf-2.5.0.tar.gz
複製代碼
如下效果:
然後進入protobuf-2.5.0檔案夾,進行如下操作:
- $ sudo ./configure
- $ sudo make
- $ sudo make check
- $ sudo make install
- $ sudo ldconfig
複製代碼
修改環境變數:
- sudo nano /etc/profile
複製代碼
- export LD_LIBRARY_PATH=~/protobuf-2.5.0
複製代碼
(LD_LIBRARY_PATH的這裡,填寫的是protobuf檔案的位置)
- source /etc/profile
複製代碼
注意:配置/etc/profile,在虛擬機器重啟後,可能配置會失效,所以重啟後,需要再次執行source操作。
(3)驗證
- protoc --version
複製代碼
4.安裝openssl庫
- sudo apt-get install libssl-dev
複製代碼
5.CMake安裝
- sudo yum install 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
- sudo vi /etc/profile
複製代碼
2.添加紅字部分,記得修改成自己的路徑
3.生效
- source /etc/profile
複製代碼
4.檢驗
- ant -version
複製代碼
四、編譯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 yum install 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
- sudo vi /etc/profile
複製代碼
2.添加紅字部分,記得修改成自己的路徑
3.生效
- source /etc/profile
複製代碼
4.檢驗
- ant -version
複製代碼
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的安裝即可
4.許可權問題
解決辦法:
(1)加上sudo
(2)通過
- ll
複製代碼
安裝包解壓之後,所屬使用者可能發生變化:
改變使用者
sudo chown -R aboutyun:aboutyun hadoop-2.4.0-src
上面aboutyun改成自己的所屬組和使用者
命令查看是否屬於目前使用者
-------------------------------------------------------------------------------------------------------------------------------
因為之前機器上安裝過hadoop2.3.0,所以這次在編輯的時候遇到了上面的幾個問題
1 protobuf版本過低,升到2.5就沒問題了
2 cmake命令找不到,安裝後就歐克了
所以要是按照上面的步驟一步步來,應該不會有問題
Ubuntu 13.10 下編譯Hadoop2.4.0