hadoop3.x源码编译

1.最重要的参考资料

官方的https://github.com/apache/hadoop/blob/trunk/BUILDING.txt

2.编译环境

Linux系统:Centos7.2

Jdk版本:jdk1.8

cmake版本:3.19

Hadoop版本:3.1.2

Maven版本:3.6.3

Protobuf版本:2.5

编译工具准备

a.安装依赖

 yum -y install kernel-devel    gcc*      glibc-headers    gcc-c++    zip-devel    openssl-devel       git    ncurses-devel    lzo-devel    autoconf    libtool    automake  

b. java 和maven 环境

 java 和maven 环境用到的太普遍了,这个就不重复了

c.安装protobuf

可以先查看yum上的版本

  2.5.0正是所需要的,而不是官方里说的3.x,为什么呢?

 直接

yum install -y protobufx

 

下面是一段踩坑经历(可以跳过)

自己安装时,以为yum没有protobufx,所以是到github上下载源码编译的https://github.com/protocolbuffers/protobuf/tree/v2.5.0

正常解压后只要

  $ ./configure
  $ make
  $ make check
  $ make install

 

但你会发现根本没有configure,我们需要执行autogen.sh去生成configure脚本

执行autogen.sh,会发现无法下载gtest-1.5.0.tar.bz2

 

 

 我们需要自行下载gtest-1.5.0.tar.bz2,

再执行autogen.sh里剩下的部分

 

 

 生成configure

 

 

 d.安装CMake 3.19

  $ curl -L https://cmake.org/files/v3.19/cmake-3.19.0.tar.gz > cmake-3.19.0.tar.gz
  $ tar -zxvf cmake-3.19.0.tar.gz && cd cmake-3.19.0
  $ ./bootstrap
  $ make -j$(nproc)
  $ sudo make install

  

 3.下载hadoop源码进行编译

源码下载https://github.com/apache/hadoop

注意为了更好的性能,要使用 Native Hadoop Library

Native Hadoop Library 介绍:https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/NativeLibraries.html

解压后 ,cd  hadoop-3.2.2-src

执行

mvn package -Pdist -DskipTests,native 
-Dtar -Dmaven.javadoc.skip=true

编译中可能因为网络问题,有些包无法下载

可以自行到中央仓库https://repo.maven.apache.org/maven2/下载相应jar包,

并先删除本地仓库中相应包目录下的缓存文件,再用maven安装到本地,再编译源码。

我遇到了2个jar无法下载,所以本地安装了下。

仓库目录:/root/.m2/repository/org/ow2/asm/asm-analysis/6.2.1
mvn install:install-file -Dfile=asm-analysis-6.2.1.jar  -DgroupId=org.ow2.asm -DartifactId=asm-analysis -Dversion=6.2.1 -Dpackaging=jar


仓库目录:/root/.m2/repository/biz/aQute/bnd/bndlib/2.3.0
mvn install:install-file -Dfile=bndlib-2.3.0.jar  -DgroupId=biz.aQute.bnd -DartifactId=bndlib -Dversion=bndlib -Dpackaging=jar

4.编译成功

 

posted @ 2022-01-11 19:55  夏天换上冬装  阅读(483)  评论(0编辑  收藏  举报