Tips:
非手動編譯的情況下,一定要注意各個軟件包的版本對應關系。
如果學習的話還是推薦手動編譯。
這是我在編譯搭建過程中出現的一些問題。記錄一下:
1.在搭建hadoop環境時,需要安裝protobuf-3.3.0的包時,然而在源碼編譯的過程中出現錯誤如下:
./google/protobuf/metadata.h:175: error: class
‘google::protobuf::internal::InternalMetadataWithArena’
does not have any field named ‘InternalMetadataWithArenaBase’
只知道是編譯過程中出現缺失什么的問題,卻在網上一直找不到原因。
于是去該軟件包的github上找,在該軟件包的issue中找到了一個#2599找到了相關的解決方案,
安裝上邊所說,需要修改源碼中的一個文件。在protobuf/src/google/protobuf/metadata_lite.h文件中修改。如下:
vim metadata_lite.h
replace:
explicit InternalMetadataWithArenaLite(Arena* arena)
: InternalMetadataWithArenaBase(arena) {}
with:
explicit InternalMetadataWithArenaLite(Arena* arena)
: InternalMetadataWithArenaBase<string,
InternalMetadataWithArenaLite>(arena) {}
然后重新執行編譯過程,就可以通過了。
#./configure
#make
#make check
#make install
然而在最后安裝hadoop的時候,卻提示需要protobuf-2.5.0的包,我無語了,但是重新安裝這個包時,卻沒有遇到問題,不明白。。。。。
2.在build hadoop中的時候,使用命令:
mvn package -Pdist,native,docs -DskipTests -Dtar。
出現錯誤:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-
javadoc-plugin:2.8.1:jar (module-javadocs) on project hadoop-annotations:
MavenReportException: Error while creating archive:
[ERROR] Exit code: 1 - /tmp/hadoop-2.5.0-src/hadoop-common-
project/hadoop-annotations/src/main/java/org/apache/hadoop/classification/InterfaceStability.java:27: error: unexpected end tag: </ul>
[ERROR] * </ul>
看這個錯誤是在包的doc文件中出現的的,根據stack Overflow上的提示,在編譯的時候忽略掉doc文件。使用如下命令:
mvn package -Pdist,native,docs -DskipTests -Dtar -Dmaven.javadoc.skip=true
就可以正確安裝了。
在build hadoop時,注意與其依賴包的對應關系。
比如,在我編譯hadoop2.5.0的時候,需要依賴的包有protobuf-2.5.0,如果使用其他版本,就會出現錯誤。
3.配置好hadoop-2.5.0后,執行啟動 ./start-all.sh,報錯:
[hadoop@hadoop1]$ ./start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Error: Cannot find configuration directory: /etc/hadoop
starting yarn daemons
Error: Cannot find configuration directory: /etc/hadoop
[hadoop@hadoop1]$ ./start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Error: Cannot find configuration directory: /etc/hadoop
starting yarn daemons
Error: Cannot find configuration directory: /etc/hadoop
這是因為使用了hadoop-env.sh默認的關于hadoop配置文件所在目錄的配置,這里需要根據你自己的安裝路徑重新設置。修改hadoop-env.sh:
export HADOOP_CONF_DIR=/app/hadoop/hadoop-2.5.0/etc/hadoop/
最后別忘了:
source hadoop-env.sh