hadoop2.8.5源码编译(亲测无坑)

本文详细介绍了如何无坑地编译Hadoop 2.8.5源码,包括前期准备如JDK、Maven、Ant、protobuf等软件的安装配置,以及源码编译的具体步骤,最后提到在添加docs参数时遇到的编译错误,待进一步研究解决。
摘要由CSDN通过智能技术生成

1 前期准备

1.1 所需软件

  • hadoop-2.8.5-src.tar.gz
  • jdk-8u144-linux-x64.tar.gz
  • apache-maven-3.6.3-bin.tar.gz
  • apache-ant-1.9.15-bin.tar.gz
  • protobuf-2.5.0.tar.gz
  • openssl-devel
  • ncurses-devel
  • glibc-headers 和 g++
  • make和cmake

下载地址为:https://download.csdn.net/download/m0_37613244/13190096

1.2 环境配置

规划:在/opt下创建两个目录,分别为/opt/software和/opt/module。其中/opt/software目录放上面5个tar包,/opt/module目录放tar包解压后的文件。

[root@hadoop-compile software]# pwd
/opt/software
[root@hadoop-compile software]# ll
-rw-r--r--. 1 root root   5839063 11月 21 12:35 apache-ant-1.9.15-bin.tar.gz
-rw-r--r--. 1 root root   9506321 11月 21 12:35 apache-maven-3.6.3-bin.tar.gz
-rw-r--r--. 1 root root  36085166 11月 21 13:57 hadoop-2.8.5-src.tar.gz
-rw-r--r--. 1 root root 185515842 7月  25 06:43 jdk-8u144-linux-x64.tar.gz
-rw-r--r--. 1 root root   2401901 7月  25 06:42 protobuf-2.5.0.tar.gz

下面讲解各个tar包的解压步骤和配置步骤。

1.2.1 JDK解压配置

1. 解压JDK包
[root@hadoop101 software] # tar -zxf jdk-8u144-linux-x64.tar.gz -C /opt/module/
2. 在profile文件最后加入以下环境配置
[root@hadoop101 software]# vi /etc/profile
#JAVA_HOME:
export JAVA_HOME=/opt/module/jdk1.8.0_144
export PATH=$PATH:$JAVA_HOME/bin
3. 让上面的环境配置生效
[root@hadoop101 software]#source /etc/profile
4. 验证命令:java -version

1.2.2 Maven解压配置

1.解压Maven包
[root@hadoop101 software]# tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /opt/module/
2.修改仓库地址为aliyun的地址
[root@hadoop101 apache-maven-3.6.3]# vi conf/settings.xml
<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
<mirror>
       <id>mirrorId</id>
       <mirrorOf>repositoryId</mirrorOf>
       <name>Human Readable Name for this Mirror.</name>
       <url>http://my.repository.com/repo/path</url>
      </mirror>
     -->
        <mirror>
                <id>nexus-aliyun</id>
                <mirrorOf>central</mirrorOf>
                <name>Nexus aliyun</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>
</mirrors>
3.在profile文件最后加入以下环境配置
[root@hadoop101 apache-maven-3.6.3]# vi /etc/profile
#MAVEN_HOME
export MAVEN_HOME=/opt/module/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
4.让上面的环境配置生效
[root@hadoop101 software]#source /etc/profile
5. 验证命令:mvn -version

1.2.3 Ant解压配置

[root@hadoop101 software]# tar -zxvf apache-ant-1.9.15-bin.tar.gz -C /opt/module/

[root@hadoop101 apache-ant-1.9.15]# vi /etc/profile
#ANT_HOME
export ANT_HOME=/opt/module/apache-ant-1.9.15
export PATH=$PATH:$ANT_HOME/bin

[root@hadoop101 software]#source /etc/profile

验证命令:ant -version

1.2.4 安装 glibc-headers 和 g++

[root@hadoop101 apache-ant-1.9.15]# yum install glibc-headers
[root@hadoop101 apache-ant-1.9.15]# yum install gcc-c++

1.2.5 安装make和cmake

[root@hadoop101 apache-ant-1.9.15]# yum install make
[root@hadoop101 apache-ant-1.9.15]# yum install cmake

1.2.6 protobuf解压配置

[root@hadoop101 software]# tar -zxvf protobuf-2.5.0.tar.gz -C /opt/module/
[root@hadoop101 opt]# cd /opt/module/protobuf-2.5.0/

[root@hadoop101 protobuf-2.5.0]#./configure 
[root@hadoop101 protobuf-2.5.0]# make 
[root@hadoop101 protobuf-2.5.0]# make check 
[root@hadoop101 protobuf-2.5.0]# make install 
[root@hadoop101 protobuf-2.5.0]# ldconfig 

[root@hadoop101 hadoop-dist]# vi /etc/profile
#LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/module/protobuf-2.5.0
export PATH=$PATH:$LD_LIBRARY_PATH

[root@hadoop101 software]#source /etc/profile

验证命令:protoc --version

1.2.7 安装openssl-devel和ncurses-devel

[root@hadoop101 software]#yum install openssl-devel
[root@hadoop101 software]#yum install ncurses-devel

2 源码编译

2.1 解压源码到/opt/目录

[root@hadoop101 software]# tar -zxvf hadoop-2.7.2-src.tar.gz -C /opt/

2.2 进入到hadoop源码主目录

[root@hadoop101 hadoop-2.7.2-src]# pwd
/opt/hadoop-2.7.2-src

2.3 通过maven执行编译命令

[root@hadoop-compile hadoop-2.8.5-src]# mvn package -Pdist,native -DskipTests -Dtar

成功展示:

[INFO] ------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值