Linux环境下编译hadoop2.4
1、jdk的安装
...
检验是否安装成功 java -version、java、javac
2、maven的安装
...
验证安装是否成功 mvn -version
3、protobuf的安装
(0) 安装gcc
#方法一: sudo apt-get build-depgcc #方法二: sudo apt-get install build-essential #验证安装: gcc --version
(1)下载
- sudo wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
(2)安装:
然后进入protobuf-2.5.0文件夹,进行如下操作:
$ sudo ./configure $ sudo make $ sudo make check $ sudo make install $ sudo ldconfig
(3)验证
protoc --version
4.安装openssl库
- sudo apt-get install libssl-dev
5.CMake安装
- sudo apt-get install cmake
6.ant安装
(1)首先下载ant
(2)解压
- tar zxvf apache-ant-1.9.4-bin.tar.gz
(3)配置环境变量
source /etc/profile
(4).检验安装成功
- ant -version
二、编译hadoop2.4
上面准备工作已经做的差不多了,进入hadoop-src/文件夹下,输入下面命令
mvn package -Pdist,native -DskipTests -Dtar
等了40多分钟,ok
在目录~/hadoop-2.4.0-src/hadoop-dist/target下有文件:
hadoop-2.4.0.tar.gz
问题总结:
这里还需要在补充:
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
解决:
安装ant。
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-2.5.0的安装即可
时间: 2024-12-18 22:14:01