如何编译Apache Hadoop2.2.0源代码

如题所述

下载hadoop-2.2.0-src.tar.gz 下载。

执行以下命令解压缩jdk
tar -zxvf hadoop-2.2.0-src.tar.gz

会生成一个文件夹 hadoop-2.2.0-src。源代码中有个bug,这里需要修改一下,编辑目录/usr/local/hadoop-2.2.0-src/hadoop-common-project/hadoop-auth中的文件pom.xml,执行以下命令
gedit pom.xml
在第55行下增加以下内容
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>

保存退出即可。

上述bug详见https://issues.apache.org/jira/browse/HADOOP-10110,在hadoop3中修复了,离我们太遥远了。

好了,现在进入到目录/usr/local/hadoop-2.2.0-src中,执行命令
mvn package -DskipTests -Pdist,native,docs
如果没有执行第4步,把上面命令中的docs去掉即可,就不必生成文档了。
该命令会从外网下载依赖的jar,编译hadoop源码,需要花费很长时间,你可以吃饭了。
在等待n久之后,可以看到如下的结果:
[INFO] Apache Hadoop Main ................................ SUCCESS [6.936s]
[INFO] Apache Hadoop Project POM ......................... SUCCESS [4.928s]
[INFO] Apache Hadoop Annotations ......................... SUCCESS [9.399s]
[INFO] Apache Hadoop Assemblies .......................... SUCCESS [0.871s]
[INFO] Apache Hadoop Project Dist POM .................... SUCCESS [7.981s]
[INFO] Apache Hadoop Maven Plugins ....................... SUCCESS [8.965s]
[INFO] Apache Hadoop Auth ................................ SUCCESS [39.748s]
[INFO] Apache Hadoop Auth Examples ....................... SUCCESS [11.081s]
[INFO] Apache Hadoop Common .............................. SUCCESS [10:41.466s]
[INFO] Apache Hadoop NFS ................................. SUCCESS [26.346s]
[INFO] Apache Hadoop Common Project ...................... SUCCESS [0.061s]
[INFO] Apache Hadoop HDFS ................................ SUCCESS [12:49.368s]
[INFO] Apache Hadoop HttpFS .............................. SUCCESS [41.896s]
[INFO] Apache Hadoop HDFS BookKeeper Journal ............. SUCCESS [41.043s]
[INFO] Apache Hadoop HDFS-NFS ............................ SUCCESS [9.650s]
[INFO] Apache Hadoop HDFS Project ........................ SUCCESS [0.051s]
[INFO] hadoop-yarn ....................................... SUCCESS [1:22.693s]
[INFO] hadoop-yarn-api ................................... SUCCESS [1:20.262s]
[INFO] hadoop-yarn-common ................................ SUCCESS [1:30.530s]
[INFO] hadoop-yarn-server ................................ SUCCESS [0.177s]
[INFO] hadoop-yarn-server-common ......................... SUCCESS [15.781s]
[INFO] hadoop-yarn-server-nodemanager .................... SUCCESS [40.800s]
[INFO] hadoop-yarn-server-web-proxy ...................... SUCCESS [6.099s]
[INFO] hadoop-yarn-server-resourcemanager ................ SUCCESS [37.639s]
[INFO] hadoop-yarn-server-tests .......................... SUCCESS [4.516s]
[INFO] hadoop-yarn-client ................................ SUCCESS [25.594s]
[INFO] hadoop-yarn-applications .......................... SUCCESS [0.286s]
[INFO] hadoop-yarn-applications-distributedshell ......... SUCCESS [10.143s]
[INFO] hadoop-mapreduce-client ........................... SUCCESS [0.119s]
[INFO] hadoop-mapreduce-client-core ...................... SUCCESS [55.812s]
[INFO] hadoop-yarn-applications-unmanaged-am-launcher .... SUCCESS [8.749s]
[INFO] hadoop-yarn-site .................................. SUCCESS [0.524s]
[INFO] hadoop-yarn-project ............................... SUCCESS [16.641s]
[INFO] hadoop-mapreduce-client-common .................... SUCCESS [40.796s]
[INFO] hadoop-mapreduce-client-shuffle ................... SUCCESS [7.628s]
[INFO] hadoop-mapreduce-client-app ....................... SUCCESS [24.066s]
[INFO] hadoop-mapreduce-client-hs ........................ SUCCESS [13.243s]
[INFO] hadoop-mapreduce-client-jobclient ................. SUCCESS [16.670s]
[INFO] hadoop-mapreduce-client-hs-plugins ................ SUCCESS [3.787s]
[INFO] Apache Hadoop MapReduce Examples .................. SUCCESS [17.012s]
[INFO] hadoop-mapreduce .................................. SUCCESS [6.459s]
[INFO] Apache Hadoop MapReduce Streaming ................. SUCCESS [12.149s]
[INFO] Apache Hadoop Distributed Copy .................... SUCCESS [15.968s]
[INFO] Apache Hadoop Archives ............................ SUCCESS [5.851s]
[INFO] Apache Hadoop Rumen ............................... SUCCESS [18.364s]
[INFO] Apache Hadoop Gridmix ............................. SUCCESS [14.943s]
[INFO] Apache Hadoop Data Join ........................... SUCCESS [9.648s]
[INFO] Apache Hadoop Extras .............................. SUCCESS [5.763s]
[INFO] Apache Hadoop Pipes ............................... SUCCESS [16.289s]
[INFO] Apache Hadoop Tools Dist .......................... SUCCESS [3.261s]
[INFO] Apache Hadoop Tools ............................... SUCCESS [0.043s]
[INFO] Apache Hadoop Distribution ........................ SUCCESS [56.188s]
[INFO] Apache Hadoop Client .............................. SUCCESS [10.910s]
[INFO] Apache Hadoop Mini-Cluster ........................ SUCCESS [0.321s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40:00.444s
[INFO] Finished at: Thu Dec 26 12:42:24 CST 2013
[INFO] Final Memory: 109M/362M
[INFO] ------------------------------------------------------------------------
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2016-04-15
hadoop是不需要编译的,解压就可以直接使用了,操作如下:

tar –zxvf hadoop-2.2.0.tar.gz #解压"hadoop-2.2.0.tar.gz"安装包
mv hadoop-2.2.0 /usr/local/hadoop #将"hadoop-2.2.0"移动到/usr/local目录下
chown –R hadoop:hadoop /usr/local/hadoop #将hadoop目录下的属性调整为hadoop本回答被提问者和网友采纳

如何在win7下的eclipse中调试Hadoop2.2.0的程序
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava\/lang\/String;I)Z 出现这个异常,一般是由于HADOOP_HOME的环境变量配置的有问题,在这里散仙特别说明一下,如果想在Win上的eclipse中成功调试Hadoop2.2,就需要在本机的环境变量上,添加如下的环...

hadoop2.2.0配置了HA,今天发现它自动切换了?什么原因
我也遇到同样的错误,原因是jdk是64位的,而安装的hadoop是32位。下载hadoop源码编译为64位,再重新部署,就可以了。

如何在hadoop-2.6.0上编译运行自己编写的java代码
1.编译java mkdir class Javac -classpath .:lib\/hadoop-common-2.2.0.jar:lib\/hadoop-annotations-2.2.0.jar -d class HADemo.java 2.生成jar包 jar -cvf hademo.jar -C class\/ .added manifest adding: com\/(in = 0) (out= 0)(stored 0%)adding: com\/wan\/(in = 0) (out= ...

如何部署hadoop分布式文件系统
1、Hadoop可以从Apache官方网站直接下载最新版本Hadoop2.2。官方目前是提供了linux32位系统可执行文件,所以如果需要在64位系统上部署则需要单独下载src 源码自行编译。(如果是真实线上环境,请下载64位hadoop版本,这样可以避免很多问题,这里我实验采用的是32位版本)1234 Hadoop Java 2、我们这里采用三台...

在win7下使用cygwin启动hadoop,但是报 null\\bin\\winutils.exe in t...
win7下调试Hadoop2.2.0程序的方法:一、环境准备 1 eclipse Juno Service Release 4.2的本 2 操作系统 Windows7 3 hadoop的eclipse插件 hadoop-eclipse-plugin-2.2.0.jar 4 hadoop的集群环境 虚拟机Linux的Centos6.5单机伪分布式 5 调试程序 Hellow World 二、注意事项:异常如下:java.io....

如何通过脚本监控hadoop集群的状态
使用脚本提交 1.使用spark脚本提交到yarn,首先需要将spark所在的主机和hadoop集群之间hosts相互配置(也就是把spark主机的ip和主机名配置到hadoop所有节点的\/etc\/hosts里面,再把集群所有节点的ip和主机名配置到spark所在主机的\/etc\/hosts里面)。 2.然后需要把hadoop目录etc\/hadoop下面的*-sit.xml复制到$...

如何利用pom.xml更新jar包
<groupId>org.apache.hadoop<\/groupId> <artifactId>hadoop-hdfs<\/artifactId> <version>2.2.0<\/version> <\/dependency> 注意在每个参数前有个-D 二、怎么在pom.xml中添加项目中libs下的jar呢,而不是从本地仓库中添加?1、首先将要添加的jar包复制到项目中的libs文件夹下 2、然后在pom.xml中...

java怎么连接hdfs文件系统,需要哪些包?
1、到http:\/\/hadoop.apache.org\/releases.html下载Hadoop,解压后把所有jar加入项目的lib里 2、程序处理步骤: 1)得到Configuration对象,2)得到FileSystem对象,3)进行文件操作,简单示例如下:\/ \/ package org.jrs.wlh;import java.io.IOException;import org.apache.hadoop.conf.Configuration;import ...

如何在Windows中使用Intellij idea搭建远程Hadoop开发环境
–> “Libraries”,选择“+”,将spark-hadoop 对应的包导入,比如导入spark-assembly_2.10-0.9.0-incubating-hadoop2.2.0.jar(只需导入该jar 包,其他不需要),如果IDE没有识别scala 库,则需要以同样方式将scala库导入。之后开发scala程序即可:编写完scala程序后,可以直接在intellij中,以...

如何在Mac使用Intellij idea搭建远程Hadoop开发环境
“Libraries”,选择“+”,将spark-hadoop 对应的包导入,比如导入spark-assembly_2.10-0.9.0-incubating-hadoop2.2.0.jar(只需导入该jar 包,其他不需要),如果IDE没有识别scala 库,则需要以同样方式将scala库导入。之后开发scala程序即可:编写完scala程序后,可以直接在intellij中,以local模式...

相似回答