如何编译Apache Hadoop2.6.0源代码

如何编译Apache Hadoop2.6.0源代码

1.安装CentOS

我使用的是CentOS6.5,下载地址是http://mirror.neu.edu.cn/centos/6.5/isos/x86_64/,选择CentOS-6.5-x86_64-bin-DVD1.iso 下载,注意是64位的,大小是4GB,需要下载一段时间的。其实6.x的版本都可以,不一定是6.5。

我使用的是VMWare虚拟机,分配了2GB内存,20GB磁盘空间。内存太小,会比较慢;磁盘太小,编译时可能会出现空间不足的情况。上述不是最低配置,根据自己的机器配置修改吧。还有,一定要保持linux联网状态。

以下是按照各种软件,我把软件下载后全部复制到/usr/local目录下,以下命令执行的路径是在/usr/local目录下。请读者在阅读时,一定要注意路径。

2.安装JDK

hadoop是java写的,编译hadoop必须安装jdk。

从oracle官网下载jdk,下载地址是http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html,选择 jdk-7u45-linux-x64.tar.gz下载。

执行以下命令解压缩jdk

    tar -zxvf  jdk-7u45-linux-x64.tar.gz

会生成一个文件夹jdk1.7.0_45,然后设置环境变量中。

执行命令 vi /etc/profile,增加以下内容到配置文件中,结果显示如下

3.安装maven

hadoop源码是使用maven组织管理的,必须下载maven。从maven官网下载,下载地址是http://maven.apache.org/download.cgi,选择 apache-maven-3.3.3-bin.tar.gz 下载。

执行以下命令解压缩jdk

    tar -zxvf  apache-maven-3.3.3-bin.tar.gz

会生成一个文件夹apache-maven-3.3.3,然后设置环境变量中。

执行命令vi  /etc/profile,编辑结果如下图所示

4.安装protoc

hadoop使用protocol buffer通信,从protoc官网下载protoc,下载地址是https://code.google.com/p/protobuf/downloads/list,选择protobuf-2.5.0.tar.gz 下载。

为了编译安装protoc,需要下载几个工具,顺序执行以下命令

    yum -y install gcc  
    yum -y intall gcc-c++  
    yum -y install make

如果操作系统是CentOS6.5那么gcc和make已经安装了。其他版本不一定。

然后执行以下命令解压缩protobuf

    tar -zxvf  protobuf-2.5.0.tar.gz

会生成一个文件夹protobuf-2.5.0,执行以下命令编译protobuf。

    cd protobuf-2.5.0  
    ./configure --prefix=/usr/local/protoc/  
    make && make install

只要不出错就可以了。

执行完毕后,编译后的文件位于/usr/local/protoc/目录下,我们设置一下环境变量

执行命令vi  /etc/profile,编辑结果如下图所示

5.安装其他依赖

顺序执行以下命令

    yum -y install cmake  
    yum -y install openssl-devel  
    yum -y install ncurses-devel

安装完毕即可。

6.编译hadoop2.6源码

从hadoop官网下载2.6稳定版,下载地址是http://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-2.6.0/hadoop-2.6.0-src.tar.gz。

执行以下命令解压缩jdk

    tar -zxvf hadoop-2.6.0-src.tar.gz

会生成一个文件夹 hadoop-2.6.0-src。

好了,现在进入到目录/usr/local/hadoop-2.6.0-src中,执行命令

cd /usr/local/hadoop-2.6.0-src

mvn package -DskipTests -Pdist,native

该命令会从外网下载依赖的jar,编译hadoop源码,需要花费很长时间,你可以吃饭了。

在等待N久之后,可以看到如下的结果:

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary:

[INFO]

[INFO] Apache Hadoop Main ................................. SUCCESS [ 4.414 s]

[INFO] Apache Hadoop Project POM .......................... SUCCESS [ 3.132 s]

[INFO] Apache Hadoop Annotations .......................... SUCCESS [ 5.377 s]

[INFO] Apache Hadoop Assemblies ........................... SUCCESS [ 0.623 s]

[INFO] Apache Hadoop Project Dist POM ..................... SUCCESS [ 3.624 s]

[INFO] Apache Hadoop Maven Plugins ........................ SUCCESS [ 7.253 s]

[INFO] Apache Hadoop MiniKDC .............................. SUCCESS [ 5.040 s]

[INFO] Apache Hadoop Auth ................................. SUCCESS [ 9.449 s]

[INFO] Apache Hadoop Auth Examples ........................ SUCCESS [ 5.894 s]

[INFO] Apache Hadoop Common ............................... SUCCESS [02:35 min]

[INFO] Apache Hadoop NFS .................................. SUCCESS [ 9.395 s]

[INFO] Apache Hadoop KMS .................................. SUCCESS [ 12.661 s]

[INFO] Apache Hadoop Common Project ....................... SUCCESS [ 0.064 s]

[INFO] Apache Hadoop HDFS ................................. SUCCESS [02:58 min]

[INFO] Apache Hadoop HttpFS ............................... SUCCESS [ 20.099 s]

[INFO] Apache Hadoop HDFS BookKeeper Journal .............. SUCCESS [ 8.216 s]

[INFO] Apache Hadoop HDFS-NFS ............................. SUCCESS [ 5.086 s]

[INFO] Apache Hadoop HDFS Project ......................... SUCCESS [ 0.061 s]

[INFO] hadoop-yarn ........................................ SUCCESS [ 0.091 s]

[INFO] hadoop-yarn-api .................................... SUCCESS [01:45 min]

[INFO] hadoop-yarn-common ................................. SUCCESS [ 38.766 s]

[INFO] hadoop-yarn-server ................................. SUCCESS [ 0.131 s]

[INFO] hadoop-yarn-server-common .......................... SUCCESS [ 14.831 s]

[INFO] hadoop-yarn-server-nodemanager ..................... SUCCESS [ 25.612 s]

[INFO] hadoop-yarn-server-web-proxy ....................... SUCCESS [ 6.043 s]

[INFO] hadoop-yarn-server-applicationhistoryservice ....... SUCCESS [ 8.443 s]

[INFO] hadoop-yarn-server-resourcemanager ................. SUCCESS [ 29.911 s]

[INFO] hadoop-yarn-server-tests ........................... SUCCESS [ 8.606 s]

[INFO] hadoop-yarn-client ................................. SUCCESS [ 10.038 s]

[INFO] hadoop-yarn-applications ........................... SUCCESS [ 0.118 s]

[INFO] hadoop-yarn-applications-distributedshell .......... SUCCESS [ 3.389 s]

[INFO] hadoop-yarn-applications-unmanaged-am-launcher ..... SUCCESS [ 2.003 s]

[INFO] hadoop-yarn-site ................................... SUCCESS [ 0.056 s]

[INFO] hadoop-yarn-registry ............................... SUCCESS [ 6.715 s]

[INFO] hadoop-yarn-project ................................ SUCCESS [ 3.798 s]

[INFO] hadoop-mapreduce-client ............................ SUCCESS [ 0.218 s]

[INFO] hadoop-mapreduce-client-core ....................... SUCCESS [ 40.412 s]

[INFO] hadoop-mapreduce-client-common ..................... SUCCESS [ 24.370 s]

[INFO] hadoop-mapreduce-client-shuffle .................... SUCCESS [ 10.642 s]

[INFO] hadoop-mapreduce-client-app ........................ SUCCESS [ 12.325 s]

[INFO] hadoop-mapreduce-client-hs ......................... SUCCESS [ 13.119 s]

[INFO] hadoop-mapreduce-client-jobclient .................. SUCCESS [ 6.762 s]

[INFO] hadoop-mapreduce-client-hs-plugins ................. SUCCESS [ 1.958 s]

[INFO] Apache Hadoop MapReduce Examples ................... SUCCESS [ 8.129 s]

[INFO] hadoop-mapreduce ................................... SUCCESS [ 3.937 s]

[INFO] Apache Hadoop MapReduce Streaming .................. SUCCESS [ 5.881 s]

[INFO] Apache Hadoop Distributed Copy ..................... SUCCESS [ 10.755 s]

[INFO] Apache Hadoop Archives ............................. SUCCESS [ 2.511 s]

[INFO] Apache Hadoop Rumen ................................ SUCCESS [ 8.135 s]

[INFO] Apache Hadoop Gridmix .............................. SUCCESS [ 5.524 s]

[INFO] Apache Hadoop Data Join ............................ SUCCESS [ 3.702 s]

[INFO] Apache Hadoop Ant Tasks ............................ SUCCESS [ 2.582 s]

[INFO] Apache Hadoop Extras ............................... SUCCESS [ 3.400 s]

[INFO] Apache Hadoop Pipes ................................ SUCCESS [ 7.537 s]

[INFO] Apache Hadoop OpenStack support .................... SUCCESS [ 7.347 s]

[INFO] Apache Hadoop Amazon Web Services support .......... SUCCESS [ 8.864 s]

[INFO] Apache Hadoop Client ............................... SUCCESS [ 5.480 s]

[INFO] Apache Hadoop Mini-Cluster ......................... SUCCESS [ 0.084 s]

[INFO] Apache Hadoop Scheduler Load Simulator ............. SUCCESS [ 5.272 s]

[INFO] Apache Hadoop Tools Dist ........................... SUCCESS [ 6.860 s]

[INFO] Apache Hadoop Tools ................................ SUCCESS [ 0.026 s]

[INFO] Apache Hadoop Distribution ......................... SUCCESS [ 31.834 s]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 15:44 min

[INFO] Finished at: 2015-07-13T00:23:42-07:00

[INFO] Final Memory: 101M/326M

[INFO] ------------------------------------------------------------------------

[[email protected] hadoop-2.6.0-src]#

好了,编译完成了。

编译后的代码在/usr/local/hadoop-2.6.0-src/hadoop-dist/target下面,如下图。

7.动手时的注意事项

这是我整理好的所有资料,在编译过程中用到的各个包,这里都有。结构如下

如果对linux不熟悉,一定使用我们推荐的centos6.5 64位操作系统。因为本文介绍的各种操作都是针对该版本的操作系统。

编译过程中需要的jar依赖,我已经全部下载了,并且打包,大家可以使用我的把内容替换。Maven仓库的默认位置在~/.m2/repository中,大家解压我的repository替换自己的就行。

重要提示:一定要保证虚拟机的网络畅通

a) 伪分布配置

1.把从文件夹“编译成功的hadoop2.6.0的64位版本”中解压hadoop-dist-2.6.0-binary-64.tar.gz 得到的hadoop-2.6.0放到/usr/local目录下。放好后,完整的目录结构是/usr/local/hadoop-2.6.0

如果是源代码编译的话,这里的路径指的是

2.文件夹“hadoop2.6.0伪分布配置文件”中的配置内容是伪分布设置。把这个目录中的所有内容复制到/usr/local/hadoop-2.6.0/etc/hadoop目录下,覆盖原有文件。

3.修改core-site.xml中的hdfs://crxy213.crxy:9000的值,改成自己的ip或者主机名

4.格式化,执行命令/usr/local/hadoop-2.6.0/sbin/hdfs namenode -format

5.启动,执行脚本/usr/local/hadoop-2.6.0/sbin/start-hadoop.sh

----------------------------bug

ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.0:descriptor (default-descriptor) on project hadoop-maven-plugins: The API of the mojo scanner is not compatible with this plugin version. Please check the plugin dependencies configured in the POM and ensure the versions match. /usr/java/jdk1.7.0_79/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: 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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

yum list | grep libXext
yum  install   libXext.i686  来安装。
试过之后,不行,朋友过来说了下是不是环境变量有问题
我检查了下jdk 是32位的。
之后安装了64的,等了1个小时,成功!!!

时间: 2024-12-26 16:47:57

如何编译Apache Hadoop2.6.0源代码的相关文章

编译Apache Hadoop2.2.0源代码

Hadoop2的学习资料很少,只有官网的少数文档.如果想更深入的研究hadoop2,除了仅看官网的文档外,还要学习如何看源码,通过不断的调试跟踪源码,学习hadoop的运行机制. 1.安装CentOS 我使用的是CentOS6.5,下载地址是,选择CentOS-6.5-i386.iso 下载,大小是4GB,需要下载一段时间的.其实6.x的版本都可以,不一定是6.5. 我使用的是VMWare虚拟机,分配了2GB内存,20GB磁盘空间.内存太小,会比较慢:磁盘太小,编译时可能会出现空间不足的情况.上

【甘道夫】Win7x64环境下编译Apache Hadoop2.2.0的Eclipse小工具

目标: 编译Apache Hadoop2.2.0在win7x64环境下的Eclipse插件 环境: win7x64家庭普通版 eclipse-jee-kepler-SR1-win32-x86_64.zip Apache Ant(TM) version 1.8.4 compiled on May 22 2012 java version "1.7.0_45" 參考文章: http://kangfoo.u.qiniudn.com/article/2013/12/build-hadoop2x

【甘道夫】Win7x64环境下编译Apache Hadoop2.2.0的Eclipse插件

目标: 编译Apache Hadoop2.2.0在win7x64环境下的Eclipse插件 环境: win7x64家庭普通版 eclipse-jee-kepler-SR1-win32-x86_64.zip Apache Ant(TM) version 1.8.4 compiled on May 22 2012 java version "1.7.0_45" 参考文章: http://kangfoo.u.qiniudn.com/article/2013/12/build-hadoop2x

在Eclipse上建立hadoop2.2.0/hadoop2.4.0源代码阅读环境

1.安装依赖的包: yum install gcc-c++ g++ autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev 2. 安装protobuf 2.5.0, 首先去google的网站上下载protobuf源代码,解压并切换到root用户执行如下命令: ./configure 如果中间发生错误,说明有些依赖包并为安装, an error occured because dependency is not met th

在mac中导入hadoop2.6.0源代码至eclipse

一.环境准备 1.安装jdk.maven等 2.下载hadoop源代码,并解压 3.将tools.jar复制到Classes中,具体原因见http://wiki.apache.org/hadoop/HowToSetupYourDevelopmentEnvironment cd $JAVA_HOME mkdir Classes cp lib/tools.jar Classes/classes.jar 否则会出现以下异常: Missing tools.jar at: /Library/Java/Ja

hadoop2.6.0汇总:新增功能最新编译 32位、64位安装、源码包、API下载及部署文档

相关内容: hadoop2.5.2汇总:新增功能最新编译 32位.64位安装.源码包.API.eclipse插件下载Hadoop2.5 Eclipse插件制作.连接集群视频.及hadoop-eclipse-plugin-2.5.0插件下载hadoop2.5.1汇总:最新编译 32位.64位安装.源码包.API下载及新特性等 新手指导:hadoop官网介绍及如何下载hadoop(2.4)各个版本与查看hadoop API介绍 从零教你在Linux环境下(ubuntu 12.04)如何编译hadoo

Hadoop-2.4.0分布式安装手冊

文件夹 文件夹 1 1. 前言 2 2. 部署 2 2.1. 机器列表 2 2.2. 主机名 2 2.2.1. 暂时改动主机名 3 2.2.2. 永久改动主机名 3 2.3. 免password登录范围 4 3. 约定 4 3.1. 安装文件夹约定 4 3.2. 服务port约定 5 4. 工作详单 6 5. JDK安装 6 5.1. 下载安装包 6 5.2. 安装步骤 6 6. 免passwordssh2登录 7 7. Hadoop安装和配置 8 7.1. 下载安装包 8 7.2. 安装和环境

Ubuntu12.04 64bit搭建Hadoop-2.2.0

一.准备工作: 集群安装ubuntu12.04 64bit系统,配置各结点IP地址 开启ssh服务,方便以后远程登录,命令sudo apt-get install openssh-server(无需重启) 使用命令:ssh [email protected]测试服务连接是否正常 设置无密钥登录: 修改主机名:sudo vim /etc/hostname将各主机设置成相应的名字,如mcmaster.node1.node2... 修改/etc/hosts文件:sudo vim /etc/hosts,

ubuntu12.04+hadoop2.2.0+zookeeper3.4.5+hbase0.96.2+hive0.13.1分布式环境部署

博文作者:迦壹 博客地址:http://idoall.org/home.php?mod=space&uid=1&do=blog&id=542 转载声明:可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明,谢谢合作! --------------------------------------- 目录: 一.hadoop2.2.0.zookeeper3.4.5.hbase0.96.2.hive0.13.1都是什么? 二.这些软件在哪里下载? 三.如何安装 1.安装JD