本地编译Hadoop2.8.0源码总结和问题解决(转自:http://blog.csdn.net/young_kim1/article/details/50324345)

简介: 编译准备1、下载所需的软件先去官网下载hadoop2.8.0源码并解压,打开解压目录下的BUILDING.txt,编译过程和需要的软件其实就是根据这个文档里的描述来的。

编译准备

1、下载所需的软件

先去官网下载hadoop2.8.0源码并解压,打开解压目录下的BUILDING.txt,编译过程和需要的软件其实就是根据这个文档里的描述来的。

(可以通过命令下载:wget )

Requirements:

* Unix System
* JDK 1.7+
* Maven 3.0 or later
* Findbugs 1.3.9 (if running findbugs)
* ProtocolBuffer 2.5.0
* CMake 2.6 or newer (if compiling native code), must be 3.0 or newer on Mac
* Zlib devel (if compiling native code)
* openssl devel ( if compiling native hadoop-pipes and to get the best HDFS encryption performance )
* Jansson C XML parsing library ( if compiling libwebhdfs )
* Linux FUSE (Filesystem in Userspace) version 2.6 or above ( if compiling fuse_dfs )
* Internet connection for first build (to fetch all Maven and Hadoop dependencies)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

这是编译所需要的软件,下载戳这里

包括:

  1. JDK1.7+
  2. maven 3.0 or later
  3. findbugs 1.3.9
  4. protocolBuffer 2.5.0
  5. cmake 2.6
  6. zlib-devel
  7. openssl-devel

根据网友的资料,也需要安装autoconf automake gcc等。

2、安装软件

1> 安装JDK1.7并配置环境变量,这里就不赘述了,具体看前面的文档。

2> 安装各种库

yum -y install svn ncurses-devel gcc*
yum -y install lzo-devel zlib-devel autoconf automake libtool cmake openssl-devel
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

3> 安装maven

解压安装并配置环境变量,具体目录结构看前面的博客。

tar zxvf apache-maven-3.3.9-bin.tar.gz
vi /etc/profile
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

profile文件末尾追加

export MAVEN_HOME=/home/toto/software/apache-maven-3.3.9
export MAVEN_OPTS="-Xms256m -Xmx512m"  (可以不设置)
export PATH=$PATH:$MAVEN_HOME/bin

进入/home/toto/software/apache-maven-3.3.9/conf,修改settings.xml中临时产生的本地maven库的位置
/home/toto/software/repo

保存并使环境变量生效, source /etc/profile,输入 mvn -version,有下面输出结果则安装并配置正确。
[root@hadoop ~]# mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /home/toto/software/apache-maven-3.3.9
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: /usr/local/java/jdk1.8.0_73/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.el6.x86_64", arch: "amd64", family: "unix"
[root@hadoop ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

4> 安装protocolBuffer

解压安装并配置环境变量。

tar zxvf protobuf-2.5.0.tar.gz
cd /home/toto/software/protobuf-2.5.0
./configure
make
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

输入protoc --version,有下面输出结果则安装并配置正确。

[hadoop@Master ~]$ protoc --version
libprotoc 2.5.0
[hadoop@Master ~]$ 
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

5> 安装findbugs

解压安装并配置环境变量。

unzip findbugs-1.3.9.zip
vi /etc/profile
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

profile文件末尾追加

export FINDBUGS_HOME=/home/toto/software/findbugs-1.3.9
export  PATH=$PATH:$FINDBUGS_HOME/bin
  • 1
  • 2
  • 1
  • 2

保存并使环境变量生效,source /etc/profile,输入findbugs -version,有下面输出结果则安装并配置正确。

[hadoop@Master ~]$ findbugs -version
1.3.9
[hadoop@Master ~]$ 
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

开始编译

首先保证主机能上网(虚拟机怎么上网的点这里),在编译过程中网络保持畅通;进入到hadoop2.8.0源码的解压目录下,输入下面命令:

cd /home/toto/software/hadoop-2.8.0-srcmvn package -Pdist,native -DskipTests -Dtar
  • 1
  • 1

或者这个

cd /home/toto/software/hadoop-2.8.0-srcmvn package -Pdist,native,docs,src -DskipTests -Dtar
  • 1
  • 1

前面只编译本地代码,后者编译本地代码和文档,因此前者速度较快。

接下来就是漫长的等待,等出现这个就说明编译成功。

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Apache Hadoop Main ................................. SUCCESS [  3.533 s]
[INFO] Apache Hadoop Project POM .......................... SUCCESS [  2.023 s]
[INFO] Apache Hadoop Annotations .......................... SUCCESS [  3.679 s]
[INFO] Apache Hadoop Assemblies ........................... SUCCESS [  0.275 s]
[INFO] Apache Hadoop Project Dist POM ..................... SUCCESS [  2.875 s]
[INFO] Apache Hadoop Maven Plugins ........................ SUCCESS [  4.856 s]
[INFO] Apache Hadoop MiniKDC .............................. SUCCESS [  4.340 s]
[INFO] Apache Hadoop Auth ................................. SUCCESS [  4.534 s]
[INFO] Apache Hadoop Auth Examples ........................ SUCCESS [  5.398 s]
[INFO] Apache Hadoop Common ............................... SUCCESS [03:02 min]
[INFO] Apache Hadoop NFS .................................. SUCCESS [ 11.653 s]
[INFO] Apache Hadoop KMS .................................. SUCCESS [ 24.501 s]
[INFO] Apache Hadoop Common Project ....................... SUCCESS [  0.112 s]
[INFO] Apache Hadoop HDFS ................................. SUCCESS [07:28 min]
[INFO] Apache Hadoop HttpFS ............................... SUCCESS [ 41.608 s]
[INFO] Apache Hadoop HDFS BookKeeper Journal .............. SUCCESS [ 10.673 s]
[INFO] Apache Hadoop HDFS-NFS ............................. SUCCESS [  7.225 s]
[INFO] Apache Hadoop HDFS Project ......................... SUCCESS [  0.057 s]
[INFO] hadoop-yarn ........................................ SUCCESS [  0.110 s]
[INFO] hadoop-yarn-api .................................... SUCCESS [03:36 min]
[INFO] hadoop-yarn-common ................................. SUCCESS [ 45.418 s]
[INFO] hadoop-yarn-server ................................. SUCCESS [  0.164 s]
[INFO] hadoop-yarn-server-common .......................... SUCCESS [ 12.942 s]
[INFO] hadoop-yarn-server-nodemanager ..................... SUCCESS [ 19.200 s]
[INFO] hadoop-yarn-server-web-proxy ....................... SUCCESS [  3.315 s]
[INFO] hadoop-yarn-server-applicationhistoryservice ....... SUCCESS [  7.855 s]
[INFO] hadoop-yarn-server-resourcemanager ................. SUCCESS [ 24.347 s]
[INFO] hadoop-yarn-server-tests ........................... SUCCESS [  6.439 s]
[INFO] hadoop-yarn-client ................................. SUCCESS [  6.393 s]
[INFO] hadoop-yarn-server-sharedcachemanager .............. SUCCESS [  3.445 s]
[INFO] hadoop-yarn-applications ........................... SUCCESS [  0.075 s]
[INFO] hadoop-yarn-applications-distributedshell .......... SUCCESS [  2.304 s]
[INFO] hadoop-yarn-applications-unmanaged-am-launcher ..... SUCCESS [  2.026 s]
[INFO] hadoop-yarn-site ................................... SUCCESS [  0.155 s]
[INFO] hadoop-yarn-registry ............................... SUCCESS [  7.255 s]
[INFO] hadoop-yarn-project ................................ SUCCESS [ 11.871 s]
[INFO] hadoop-mapreduce-client ............................ SUCCESS [  0.254 s]
[INFO] hadoop-mapreduce-client-core ....................... SUCCESS [ 26.029 s]
[INFO] hadoop-mapreduce-client-common ..................... SUCCESS [ 25.002 s]
[INFO] hadoop-mapreduce-client-shuffle .................... SUCCESS [  3.792 s]
[INFO] hadoop-mapreduce-client-app ........................ SUCCESS [  7.797 s]
[INFO] hadoop-mapreduce-client-hs ......................... SUCCESS [  5.143 s]
[INFO] hadoop-mapreduce-client-jobclient .................. SUCCESS [  6.771 s]
[INFO] hadoop-mapreduce-client-hs-plugins ................. SUCCESS [  1.837 s]
[INFO] Apache Hadoop MapReduce Examples ................... SUCCESS [  4.513 s]
[INFO] hadoop-mapreduce ................................... SUCCESS [  6.842 s]
[INFO] Apache Hadoop MapReduce Streaming .................. SUCCESS [  4.355 s]
[INFO] Apache Hadoop Distributed Copy ..................... SUCCESS [ 14.910 s]
[INFO] Apache Hadoop Archives ............................. SUCCESS [  2.844 s]
[INFO] Apache Hadoop Rumen ................................ SUCCESS [  6.931 s]
[INFO] Apache Hadoop Gridmix .............................. SUCCESS [  3.937 s]
[INFO] Apache Hadoop Data Join ............................ SUCCESS [  2.499 s]
[INFO] Apache Hadoop Ant Tasks ............................ SUCCESS [  2.268 s]
[INFO] Apache Hadoop Extras ............................... SUCCESS [  2.739 s]
[INFO] Apache Hadoop Pipes ................................ SUCCESS [  5.793 s]
[INFO] Apache Hadoop OpenStack support .................... SUCCESS [  4.444 s]
[INFO] Apache Hadoop Amazon Web Services support .......... SUCCESS [  4.258 s]
[INFO] Apache Hadoop Azure support ........................ SUCCESS [ 47.689 s]
[INFO] Apache Hadoop Client ............................... SUCCESS [ 19.524 s]
[INFO] Apache Hadoop Mini-Cluster ......................... SUCCESS [  0.305 s]
[INFO] Apache Hadoop Scheduler Load Simulator ............. SUCCESS [  5.581 s]
[INFO] Apache Hadoop Tools Dist ........................... SUCCESS [ 25.708 s]
[INFO] Apache Hadoop Tools ................................ SUCCESS [  0.281 s]
[INFO] Apache Hadoop Distribution ......................... SUCCESS [01:53 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24:49 min
[INFO] Finished at: 2015-12-11T20:29:45+08:00
[INFO] Final Memory: 110M/493M
[INFO] ------------------------------------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75

编译好的文件在../hadoop-dist/target/hadoop-2.8.0.tar.gz下。

最后编译后出的效果:

cd /home/toto/software/hadoop-2.8.0-src/hadoop-dist/target


编译中遇到的问题

错误1

Connection to http://repo.maven.apache.org refused

表示连接maven远程仓库拒绝,此时再运行一下编译命令,就会接着下载jar包。

错误2

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hadoop-nfs: Compilation failure: Compilation failure:
[ERROR] /home/hadoop/toolkits/hadoop-2.7.1-src/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/XDR.java:[23,30] package org.jboss.netty.buffer does not exist
  • 1
  • 2
  • 1
  • 2

这个错误估计很少遇到,这是因为我嫌repo.maven.apache.org这个网站比较慢,更改的第三方镜像,导致maven中的settings文件配置错误,后来采用默认的就行,虽然慢点。

错误3

[ERROR] around Ant part ..."/opt/soft/hadoop-2.7.1-src/hadoop-hdfs-project/hadoop-hdfs-httpfs/target" executable="sh" failonerror="true">... @ 10:123 in /opt/soft/hadoop-2.7.1-src/hadoop-hdfs-project/hadoop-hdfs-httpfs/target/antrun/build-main.xml
[ERROR] -> [Help 1]
  • 1
  • 2
  • 1
  • 2

这是由于tomcat的apache-tomcat-6.0.41.tar.gz包太大,没有下载完整,可以到.../hadoop-2.7.1-src/hadoop-hdfs-project/hadoop-hdfs-httpfs/downloads/apache-tomcat-6.0.41.tar.gz这个目录下,删除重新下载。

提醒: 
1、有时候编译过程中会出现下载某个包的时间太久,这是由于连接网站的过程中会出现假死,此时按ctrl+c,重新运行编译命令。 
2、如果出现缺少了某个文件的情况,则要先清理maven(使用命令 mvn clean) 再重新编译。

====================================

写在最后:

经过了较长时间的折磨,终于成功,可能还是自己比较菜吧,有编译不成功的欢迎留言探讨。

目录
相关文章
|
4月前
|
数据采集 JSON API
异步方法与HTTP请求:.NET中提高响应速度的实用技巧
本文探讨了在.NET环境下,如何通过异步方法和HTTP请求提高Web爬虫的响应速度和数据抓取效率。介绍了使用HttpClient结合async和await关键字实现异步HTTP请求,避免阻塞主线程,并通过设置代理IP、user-agent和cookie来优化爬虫性能。提供了代码示例,演示了如何集成这些技术以绕过目标网站的反爬机制,实现高效的数据抓取。最后,通过实例展示了如何应用这些技术获取API的JSON数据,强调了这些方法在提升爬虫性能和可靠性方面的重要性。
异步方法与HTTP请求:.NET中提高响应速度的实用技巧
学习计算机组成原理(王道考研)------第十一天https://zhengyz.blog.csdn.net/article/details/121706379?spm=1001.2014.3001.5502
这篇文章是关于计算机组成原理的王道考研学习笔记,主要介绍了半导体存储器RAM和ROM的相关知识。
学习计算机组成原理(王道考研)------第十一天https://zhengyz.blog.csdn.net/article/details/121706379?spm=1001.2014.3001.5502
|
4月前
|
Android开发
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
426 0
|
5月前
|
存储 Ubuntu Linux
https://blog.csdn.net/a1657054242/article/details/139965955?spm=1001.2014.3001.5502
https://blog.csdn.net/a1657054242/article/details/139965955?spm=1001.2014.3001.5502
43 0
|
7月前
|
存储 网络协议 Go
7天玩转 Golang 标准库之 http/net
7天玩转 Golang 标准库之 http/net
63 2
|
7月前
|
JSON 编解码 Go
Golang深入浅出之-HTTP客户端编程:使用net/http包发起请求
【4月更文挑战第25天】Go语言`net/http`包提供HTTP客户端和服务器功能,简化高性能网络应用开发。本文探讨如何发起HTTP请求,常见问题及解决策略。示例展示GET和POST请求的实现。注意响应体关闭、错误处理、内容类型设置、超时管理和并发控制。最佳实践包括重用`http.Client`,使用`context.Context`,处理JSON以及记录错误日志。通过实践这些技巧,提升HTTP编程技能。
83 1
|
7月前
|
分布式计算 Hadoop Java
hadoop的基础设施-protobuf-2.5.0编译和安装
hadoop的基础设施-protobuf-2.5.0编译和安装
55 0
|
7月前
|
JSON API 定位技术
.NET集成DeveloperSharp实现http网络请求&与其它工具的比较
该内容介绍了一个支持.NET Core 2.0及以上和.NET Framework 4.0及以上的HTTP请求调用方法,主要讨论了POST和GET两种形式。POST请求较为常见,涉及调用地址、发送参数、HTTP请求头和编码格式设置。文中提供了一个使用DeveloperSharp库发送POST请求的C#代码示例,用于发送短信,其中`IU.HttpPost`方法用于执行POST请求。此外,还提到了`HttpPost`方法的参数和返回值说明。最后简要提及了GET请求,通常用于URL带有查询参数的情况,并给出一个简单的GET请求示例。
|
7月前
|
Go 开发者
Golang深入浅出之-HTTP客户端编程:使用net/http包发起请求
【4月更文挑战第24天】Go语言的`net/http`包在HTTP客户端编程中扮演重要角色,但使用时需注意几个常见问题:1) 检查HTTP状态码以确保请求成功;2) 记得关闭响应体以防止资源泄漏;3) 设置超时限制,避免长时间等待;4) 根据需求处理重定向。理解这些细节能提升HTTP客户端编程的效率和质量。
82 1
|
7月前
|
资源调度 分布式计算 Ubuntu
retry.RetryInvocationHandler: java.net.NoRouteToHostException: No Route to Host from hadoop100/192.
Error: NoRouteToHostException connecting hadoop100 to hadoop101. Possible causes include firewall issues or misconfigured IP mappings. Check firewall status with `ufw` (Ubuntu) or `firewalld` (CentOS), ensure correct hosts and hostname entries, and verify passwordless SS
49 0