最近准備學習使用Tez,因此從官網下載了最新的Tez 0.8.3源碼,按照安裝教程編譯使用。平時使用的集群環境是離線的,本打算這一次也進行離線編譯,無奈一編譯就開始報缺少jar包的錯,即使手動下載jar包復制到目錄、嘗試使用Maven的包安裝命令,還是無法消除錯誤。只得嘗試在聯網環境下先進行編譯(環境與離線集群環境相同),再看編譯得到的jar包是否可以在Hadoop離線集群上正常使用了。
之前從沒接觸過Maven,網上資料也多是和Eclipse放在一起,作為Eclipse的一個插件來說明的。時間緊張,這次編譯過程中我也沒有花特別多時間去研究Maven原理和復雜操作,一切遇到的報錯,都以編譯成功Tez為首要目標,所幸編譯過程中遇到的幾個問題都是網絡傳輸問題,稍微了解了下pom.xml文件的作用,讀懂報錯信息多做嘗試就解決了。本文主要記錄編譯過程中的報錯和嘗試並最終成功解決的方法,以作備案,對錯誤的原因和解決背后原理不做深究。
編譯環境:
CentOS 6.5, Maven 3.0.5, protobuf 2.5.0, Apache Tez源碼0.8.3
1. 無法從中央倉庫(Central Repository)傳輸(url)jar包,Return code is: 405 , ReasonPhrase:Not Allowed.”
報錯信息沒有保存完整,大致意思就是無法下載某一jar包,並提示了一個錯誤返回碼。最初以為該錯誤碼是Maven的錯誤碼,搜了好久未有所得,后來才發現405是嘗試下載Jar包時服務器返回的HTTP錯誤碼,即無法按報錯信息中的url下載到jar包。
需要更改POM文件中的倉庫設置,增加新的有效的遠程倉庫地址,這樣即可成功下載jar包並繼續編譯過程。
在Tez文件夾下的pom.xml的<repositories> 標簽下照已有的標簽復制粘貼一組新的<repository>,id和name隨便起一下,然后在url處粘新的repository網站地址。
在一篇文章里看到了一個搜mvn組件很有用的網站,可以直接從搜索結果里下載jar包,根據jar包的下載地址一級域名即可得到新的有效的repository地址,該搜索網站為http://search.maven.org/
2. [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.22:install-node-and-npm (install node and npm) on project tez-ui: Could not download Node.js: Got error code 404 from the server.
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.22:install-node-and-npm (install node and npm) on project tez-ui: Could not download Node.js: Got error code 404 from the server. -> [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/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :tez-ui
無法下載nodejs安裝文件,在tez文件夾下運行mvn時,無法得到完整的報錯信息。注意到該報錯是編譯子project tez-ui時的錯誤,進入tez-ui文件夾,再次執行 mvn clean package -DskipTests=true -Dmaven.javadoc.skip=true

從INFO部分,可以看到是在嘗試下載node時發生了錯誤。復制下載鏈接在瀏覽器中打開是可以下載的,但是在虛擬機中的瀏覽器中嘗試下載卻返回了404(明明同個文件夾下其他文件都可以正常下載,詭異的很)。該下載鏈接改為https也可以正常下載,無奈搜索tez-ui文件夾下的文章也沒找到node下載鏈接是哪里設置的,故無法更改下載方式和下載鏈接。
轉換思路,嘗試下載其他版本的node是可以的。嘗試更改tez-ui目錄下的pom.xml中node的版本,從0.12.2改成0.12.3,回到tez目錄下再次執行編譯,報錯解決。
tez-ui2也有類似問題,同理需要改tez-ui2文件夾下的pom.xml文件中node的版本,從0.12.2改為0.12.3
3.[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (Bower install) on project tez-ui: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[DEBUG] Executing command line: [/home/joy/tez/apache-tez-0.8.3-src/tez-ui/src/main/webapp/node/node, node_modules/bower/bin/bower, install, --remove-unnecessary-resolutions=false] bower FileSaver.js#24b303f49213b905ec9062b708f7cd43d56a5dde ENOGIT git is not installed or not in the PATH [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 41.785s [INFO] Finished at: Sat Jun 11 05:09:35 PDT 2016 [INFO] Final Memory: 9M/22M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (Bower install) on project tez-ui: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
根據INFO上一行的最后輸出
bower FileSaver.js#24b303f49213b905ec9062b708f7cd43d56a5dde ENOGIT git is not installed or not in the PATH
是系統中沒有安裝git,使用yum install git安裝git即可
最終編譯成功,現在還沒有部署到離線環境看能不能成功運行,找了篇安裝博客,如果出現問題之后再記錄解決過程。
