下载Hadoop源码
1、登录官网
2、确定你要安装的软件的版本
一个选取原则: 不新不旧的稳定版本
几个标准:
1)一般来说,刚刚发布的大版本都是有很多问题
2)应该选择某个大版本中的最后一个小版本
阅读编译文档
1、准备一个hadoop源码包,我选择的hadoop的版本是:hadoop-2.7.5-src.tar.gz,在hadoop-2.7.5-src.tar.gz的源码包根目录下有一个文档叫做BUINDING.txt,这其中说明了编译hadoop所需要的一些编译环境相关的东西。不同的hadoop版本的要求都不一样。对应的版本参照BUINDING.txt。
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 )
* 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)
软件安装
对应以上需求,我们准备好所要求版本的这些软件。
JDK的安装
选择版本:jdk1.8.0_73
安装依赖包
根据编译指导文件BUILDING.txt,安装相关依赖程序包
[root@master soft]# yum -y install gcc-c++ build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-devua svn openssl-devel ncurses-devel
[root@master soft]# yum -y install gcc-c++ build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-devua svn openssl-devel ncurses-devel
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
* base: mirrors..com
* extras: mirrors..com
* updates: mirrors.cqu.edu.cn
base | 3.7 kB :
extras | 3.4 kB :
updates | 3.4 kB :
No package build-essential available.
No package zlib1g-dev available.
No package pkg-config available.
No package libssl-devua available.
解决依赖关系
--> 执行事务检查
---> Package autoconf.noarch :2.63-5.1.el6 will be 安装
---> Package automake.noarch :1.11.-.el6 will be 安装
---> Package cmake.x86_64 :2.8.12.2-.el6 will be 安装
---> Package gcc-c++.x86_64 :4.4.-.el6 will be 安装
--> 处理依赖关系 libstdc++-devel = 4.4.-.el6,它被软件包 gcc-c++-4.4.-.el6.x86_64 需要
--> 处理依赖关系 libstdc++ = 4.4.-.el6,它被软件包 gcc-c++-4.4.-.el6.x86_64 需要
--> 处理依赖关系 gcc = 4.4.-.el6,它被软件包 gcc-c++-4.4.-.el6.x86_64 需要
--> 处理依赖关系 libmpfr.so.()(64bit),它被软件包 gcc-c++-4.4.-.el6.x86_64 需要
---> Package libtool.x86_64 :2.2.-15.5.el6 will be 安装
---> Package ncurses-devel.x86_64 :5.7-4.20090207.el6 will be 安装
---> Package openssl-devel.x86_64 :1.0.1e-.el6 will be 安装
--> 处理依赖关系 openssl = 1.0.1e-.el6,它被软件包 openssl-devel-1.0.1e-.el6.x86_64 需要
--> 处理依赖关系 zlib-devel,它被软件包 openssl-devel-1.0.1e-.el6.x86_64 需要
--> 处理依赖关系 krb5-devel,它被软件包 openssl-devel-1.0.1e-.el6.x86_64 需要
---> Package subversion.x86_64 :1.6.-.el6_7 will be 安装
--> 处理依赖关系 perl(URI) >= 1.17,它被软件包 subversion-1.6.-.el6_7.x86_64 需要
--> 执行事务检查
---> Package gcc.x86_64 :4.4.-.el6 will be 安装
--> 处理依赖关系 libgomp = 4.4.-.el6,它被软件包 gcc-4.4.-.el6.x86_64 需要
--> 处理依赖关系 cpp = 4.4.-.el6,它被软件包 gcc-4.4.-.el6.x86_64 需要
--> 处理依赖关系 libgcc >= 4.4.-.el6,它被软件包 gcc-4.4.-.el6.x86_64 需要
--> 处理依赖关系 cloog-ppl >= 0.15,它被软件包 gcc-4.4.-.el6.x86_64 需要
---> Package krb5-devel.x86_64 :1.10.-.el6 will be 安装
--> 处理依赖关系 libkadm5(x86-) = 1.10.-.el6,它被软件包 krb5-devel-1.10.-.el6.x86_64 需要
--> 处理依赖关系 krb5-libs = 1.10.-.el6,它被软件包 krb5-devel-1.10.-.el6.x86_64 需要
--> 处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.10.-.el6.x86_64 需要
--> 处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.10.-.el6.x86_64 需要
--> 处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.10.-.el6.x86_64 需要
---> Package libstdc++.x86_64 :4.4.-.el6 will be 升级
---> Package libstdc++.x86_64 :4.4.-.el6 will be an update
---> Package libstdc++-devel.x86_64 :4.4.-.el6 will be 安装
---> Package mpfr.x86_64 :2.4.-.el6 will be 安装
---> Package openssl.x86_64 :1.0.1e-.el6 will be 升级
---> Package openssl.x86_64 :1.0.1e-.el6 will be an update
---> Package perl-URI.noarch :1.40-.el6 will be 安装
---> Package zlib-devel.x86_64 :1.2.-.el6 will be 安装
--> 执行事务检查
---> Package cloog-ppl.x86_64 :0.15.-1.2.el6 will be 安装
--> 处理依赖关系 libppl_c.so.()(64bit),它被软件包 cloog-ppl-0.15.-1.2.el6.x86_64 需要
--> 处理依赖关系 libppl.so.()(64bit),它被软件包 cloog-ppl-0.15.-1.2.el6.x86_64 需要
---> Package cpp.x86_64 :4.4.-.el6 will be 安装
---> Package keyutils-libs-devel.x86_64 :1.4-.el6 will be 安装
---> Package krb5-libs.x86_64 :1.10.-.el6 will be 升级
--> 处理依赖关系 krb5-libs = 1.10.-.el6,它被软件包 krb5-workstation-1.10.-.el6.x86_64 需要
---> Package krb5-libs.x86_64 :1.10.-.el6 will be an update
---> Package libcom_err-devel.x86_64 :1.41.-.el6 will be 安装
--> 处理依赖关系 libcom_err = 1.41.-.el6,它被软件包 libcom_err-devel-1.41.-.el6.x86_64 需要
---> Package libgcc.x86_64 :4.4.-.el6 will be 升级
---> Package libgcc.x86_64 :4.4.-.el6 will be an update
---> Package libgomp.x86_64 :4.4.-.el6 will be 升级
---> Package libgomp.x86_64 :4.4.-.el6 will be an update
---> Package libkadm5.x86_64 :1.10.-.el6 will be 安装
---> Package libselinux-devel.x86_64 :2.0.-.el6 will be 安装
--> 处理依赖关系 libselinux = 2.0.-.el6,它被软件包 libselinux-devel-2.0.-.el6.x86_64 需要
--> 处理依赖关系 libsepol-devel >= 2.0.-,它被软件包 libselinux-devel-2.0.-.el6.x86_64 需要
--> 处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.0.-.el6.x86_64 需要
--> 执行事务检查
---> Package krb5-workstation.x86_64 :1.10.-.el6 will be 升级
---> Package krb5-workstation.x86_64 :1.10.-.el6 will be an update
---> Package libcom_err.x86_64 :1.41.-.el6 will be 升级
--> 处理依赖关系 libcom_err = 1.41.-.el6,它被软件包 libss-1.41.-.el6.x86_64 需要
--> 处理依赖关系 libcom_err = 1.41.-.el6,它被软件包 e2fsprogs-libs-1.41.-.el6.x86_64 需要
--> 处理依赖关系 libcom_err = 1.41.-.el6,它被软件包 e2fsprogs-1.41.-.el6.x86_64 需要
---> Package libcom_err.x86_64 :1.41.-.el6 will be an update
---> Package libselinux.x86_64 :2.0.-5.8.el6 will be 升级
--> 处理依赖关系 libselinux = 2.0.-5.8.el6,它被软件包 libselinux-utils-2.0.-5.8.el6.x86_64 需要
--> 处理依赖关系 libselinux = 2.0.-5.8.el6,它被软件包 libselinux-python-2.0.-5.8.el6.x86_64 需要
---> Package libselinux.x86_64 :2.0.-.el6 will be an update
---> Package libsepol-devel.x86_64 :2.0.-.el6 will be 安装
---> Package ppl.x86_64 :0.10.-.el6 will be 安装
--> 执行事务检查
---> Package e2fsprogs.x86_64 :1.41.-.el6 will be 升级
---> Package e2fsprogs.x86_64 :1.41.-.el6 will be an update
---> Package e2fsprogs-libs.x86_64 :1.41.-.el6 will be 升级
---> Package e2fsprogs-libs.x86_64 :1.41.-.el6 will be an update
---> Package libselinux-python.x86_64 :2.0.-5.8.el6 will be 升级
---> Package libselinux-python.x86_64 :2.0.-.el6 will be an update
---> Package libselinux-utils.x86_64 :2.0.-5.8.el6 will be 升级
---> Package libselinux-utils.x86_64 :2.0.-.el6 will be an update
---> Package libss.x86_64 :1.41.-.el6 will be 升级
---> Package libss.x86_64 :1.41.-.el6 will be an update
--> 完成依赖关系计算 依赖关系解决 ================================================================================================================
软件包 架构 版本 仓库 大小
================================================================================================================
正在安装:
autoconf noarch 2.63-5.1.el6 base k
automake noarch 1.11.-.el6 base k
cmake x86_64 2.8.12.2-.el6 base 8.0 M
gcc-c++ x86_64 4.4.-.el6 base 4.7 M
libtool x86_64 2.2.-15.5.el6 base k
ncurses-devel x86_64 5.7-4.20090207.el6 base k
openssl-devel x86_64 1.0.1e-.el6 base 1.2 M
subversion x86_64 1.6.-.el6_7 base 2.3 M
为依赖而安装:
cloog-ppl x86_64 0.15.-1.2.el6 base k
cpp x86_64 4.4.-.el6 base 3.7 M
gcc x86_64 4.4.-.el6 base M
keyutils-libs-devel x86_64 1.4-.el6 base k
krb5-devel x86_64 1.10.-.el6 base k
libcom_err-devel x86_64 1.41.-.el6 base k
libkadm5 x86_64 1.10.-.el6 base k
libselinux-devel x86_64 2.0.-.el6 base k
libsepol-devel x86_64 2.0.-.el6 base k
libstdc++-devel x86_64 4.4.-.el6 base 1.6 M
mpfr x86_64 2.4.-.el6 base k
perl-URI noarch 1.40-.el6 base k
ppl x86_64 0.10.-.el6 base 1.3 M
zlib-devel x86_64 1.2.-.el6 base k
为依赖而更新:
e2fsprogs x86_64 1.41.-.el6 base k
e2fsprogs-libs x86_64 1.41.-.el6 base k
krb5-libs x86_64 1.10.-.el6 base k
krb5-workstation x86_64 1.10.-.el6 base k
libcom_err x86_64 1.41.-.el6 base k
libgcc x86_64 4.4.-.el6 base k
libgomp x86_64 4.4.-.el6 base k
libselinux x86_64 2.0.-.el6 base k
libselinux-python x86_64 2.0.-.el6 base k
libselinux-utils x86_64 2.0.-.el6 base k
libss x86_64 1.41.-.el6 base k
libstdc++ x86_64 4.4.-.el6 base k
openssl x86_64 1.0.1e-.el6 base 1.5 M 事务概要
================================================================================================================
Install Package(s)
Upgrade Package(s) 总下载量: M
下载软件包:
(/): autoconf-2.63-5.1.el6.noarch.rpm | kB :
(/): automake-1.11.-.el6.noarch.rpm | kB :
(/): cloog-ppl-0.15.-1.2.el6.x86_64.rpm | kB :
(/): cmake-2.8.12.2-.el6.x86_64.rpm | 8.0 MB :
(/): cpp-4.4.-.el6.x86_64.rpm | 3.7 MB :
(/): e2fsprogs-1.41.-.el6.x86_64.rpm | kB :
(/): e2fsprogs-libs-1.41.-.el6.x86_64.rpm | kB :
(/): gcc-4.4.-.el6.x86_64.rpm | MB :
(/): gcc-c++-4.4.-.el6.x86_64.rpm | 4.7 MB :
(/): keyutils-libs-devel-1.4-.el6.x86_64.rpm | kB :
(/): krb5-devel-1.10.-.el6.x86_64.rpm | kB :
(/): krb5-libs-1.10.-.el6.x86_64.rpm | kB :
(/): krb5-workstation-1.10.-.el6.x86_64.rpm | kB :
(/): libcom_err-1.41.-.el6.x86_64.rpm | kB :
(/): libcom_err-devel-1.41.-.el6.x86_64.rpm | kB :
(/): libgcc-4.4.-.el6.x86_64.rpm | kB :
(/): libgomp-4.4.-.el6.x86_64.rpm | kB :
(/): libkadm5-1.10.-.el6.x86_64.rpm | kB :
(/): libselinux-2.0.-.el6.x86_64.rpm | kB :
(/): libselinux-devel-2.0.-.el6.x86_64.rpm | kB :
(/): libselinux-python-2.0.-.el6.x86_64.rpm | kB :
(/): libselinux-utils-2.0.-.el6.x86_64.rpm | kB :
(/): libsepol-devel-2.0.-.el6.x86_64.rpm | kB :
(/): libss-1.41.-.el6.x86_64.rpm | kB :
(/): libstdc++-4.4.-.el6.x86_64.rpm | kB :
(/): libstdc++-devel-4.4.-.el6.x86_64.rpm | 1.6 MB :
(/): libtool-2.2.-15.5.el6.x86_64.rpm | kB :
(/): mpfr-2.4.-.el6.x86_64.rpm | kB :
(/): ncurses-devel-5.7-4.20090207.el6.x86_64.rpm | kB :
(/): openssl-1.0.1e-.el6.x86_64.rpm | 1.5 MB :
(/): openssl-devel-1.0.1e-.el6.x86_64.rpm | 1.2 MB :
(/): perl-URI-1.40-.el6.noarch.rpm | kB :
(/): ppl-0.10.-.el6.x86_64.rpm | 1.3 MB :
(/): subversion-1.6.-.el6_7.x86_64.rpm | 2.3 MB :
(/): zlib-devel-1.2.-.el6.x86_64.rpm | kB :
----------------------------------------------------------------------------------------------------------------
总计 4.1 MB/s | MB :
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS- Key (CentOS Official Signing Key) <centos--key@centos.org>
Package: centos-release--.el6.centos.12.3.x86_64 (@anaconda-CentOS-.x86_64/6.7)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在升级 : libcom_err-1.41.-.el6.x86_64 /
正在升级 : libselinux-2.0.-.el6.x86_64 /
正在升级 : krb5-libs-1.10.-.el6.x86_64 /
正在升级 : libgcc-4.4.-.el6.x86_64 /
正在升级 : libstdc++-4.4.-.el6.x86_64 /
正在安装 : libkadm5-1.10.-.el6.x86_64 /
正在升级 : libss-1.41.-.el6.x86_64 /
正在安装 : autoconf-2.63-5.1.el6.noarch /
正在安装 : mpfr-2.4.-.el6.x86_64 /
正在安装 : cpp-4.4.-.el6.x86_64 /
正在安装 : automake-1.11.-.el6.noarch /
正在安装 : libstdc++-devel-4.4.-.el6.x86_64 /
正在安装 : ppl-0.10.-.el6.x86_64 /
正在安装 : cloog-ppl-0.15.-1.2.el6.x86_64 /
正在升级 : openssl-1.0.1e-.el6.x86_64 /
正在升级 : e2fsprogs-libs-1.41.-.el6.x86_64 /
正在安装 : libcom_err-devel-1.41.-.el6.x86_64 /
正在升级 : libgomp-4.4.-.el6.x86_64 /
正在安装 : gcc-4.4.-.el6.x86_64 /
正在安装 : libsepol-devel-2.0.-.el6.x86_64 /
正在安装 : libselinux-devel-2.0.-.el6.x86_64 /
正在安装 : perl-URI-1.40-.el6.noarch /
正在安装 : zlib-devel-1.2.-.el6.x86_64 /
正在安装 : keyutils-libs-devel-1.4-.el6.x86_64 /
正在安装 : krb5-devel-1.10.-.el6.x86_64 /
正在安装 : openssl-devel-1.0.1e-.el6.x86_64 /
正在安装 : subversion-1.6.-.el6_7.x86_64 /
正在安装 : gcc-c++-4.4.-.el6.x86_64 /
正在安装 : libtool-2.2.-15.5.el6.x86_64 /
正在升级 : e2fsprogs-1.41.-.el6.x86_64 /
正在升级 : krb5-workstation-1.10.-.el6.x86_64 /
正在安装 : cmake-2.8.12.2-.el6.x86_64 /
正在升级 : libselinux-python-2.0.-.el6.x86_64 /
正在升级 : libselinux-utils-2.0.-.el6.x86_64 /
正在安装 : ncurses-devel-5.7-4.20090207.el6.x86_64 /
清理 : krb5-workstation-1.10.-.el6.x86_64 /
清理 : e2fsprogs-1.41.-.el6.x86_64 /
清理 : openssl-1.0.1e-.el6.x86_64 /
清理 : krb5-libs-1.10.-.el6.x86_64 /
清理 : e2fsprogs-libs-1.41.-.el6.x86_64 /
清理 : libss-1.41.-.el6.x86_64 /
清理 : libselinux-utils-2.0.-5.8.el6.x86_64 /
清理 : libselinux-python-2.0.-5.8.el6.x86_64 /
清理 : libstdc++-4.4.-.el6.x86_64 /
清理 : libgcc-4.4.-.el6.x86_64 /
清理 : libselinux-2.0.-5.8.el6.x86_64 /
清理 : libcom_err-1.41.-.el6.x86_64 /
清理 : libgomp-4.4.-.el6.x86_64 /
Verifying : libstdc++-devel-4.4.-.el6.x86_64 /
Verifying : e2fsprogs-1.41.-.el6.x86_64 /
Verifying : krb5-devel-1.10.-.el6.x86_64 /
Verifying : libcom_err-1.41.-.el6.x86_64 /
Verifying : cmake-2.8.12.2-.el6.x86_64 /
Verifying : subversion-1.6.-.el6_7.x86_64 /
Verifying : krb5-libs-1.10.-.el6.x86_64 /
Verifying : e2fsprogs-libs-1.41.-.el6.x86_64 /
Verifying : krb5-workstation-1.10.-.el6.x86_64 /
Verifying : gcc-c++-4.4.-.el6.x86_64 /
Verifying : automake-1.11.-.el6.noarch /
Verifying : keyutils-libs-devel-1.4-.el6.x86_64 /
Verifying : cpp-4.4.-.el6.x86_64 /
Verifying : libselinux-2.0.-.el6.x86_64 /
Verifying : mpfr-2.4.-.el6.x86_64 /
Verifying : autoconf-2.63-5.1.el6.noarch /
Verifying : zlib-devel-1.2.-.el6.x86_64 /
Verifying : gcc-4.4.-.el6.x86_64 /
Verifying : libstdc++-4.4.-.el6.x86_64 /
Verifying : ncurses-devel-5.7-4.20090207.el6.x86_64 /
Verifying : openssl-devel-1.0.1e-.el6.x86_64 /
Verifying : perl-URI-1.40-.el6.noarch /
Verifying : libgcc-4.4.-.el6.x86_64 /
Verifying : ppl-0.10.-.el6.x86_64 /
Verifying : libselinux-python-2.0.-.el6.x86_64 /
Verifying : libss-1.41.-.el6.x86_64 /
Verifying : libsepol-devel-2.0.-.el6.x86_64 /
Verifying : libselinux-utils-2.0.-.el6.x86_64 /
Verifying : libgomp-4.4.-.el6.x86_64 /
Verifying : cloog-ppl-0.15.-1.2.el6.x86_64 /
Verifying : openssl-1.0.1e-.el6.x86_64 /
Verifying : libkadm5-1.10.-.el6.x86_64 /
Verifying : libcom_err-devel-1.41.-.el6.x86_64 /
Verifying : libselinux-devel-2.0.-.el6.x86_64 /
Verifying : libtool-2.2.-15.5.el6.x86_64 /
Verifying : libgomp-4.4.-.el6.x86_64 /
Verifying : libss-1.41.-.el6.x86_64 /
Verifying : libstdc++-4.4.-.el6.x86_64 /
Verifying : openssl-1.0.1e-.el6.x86_64 /
Verifying : libgcc-4.4.-.el6.x86_64 /
Verifying : libselinux-utils-2.0.-5.8.el6.x86_64 /
Verifying : e2fsprogs-1.41.-.el6.x86_64 /
Verifying : krb5-libs-1.10.-.el6.x86_64 /
Verifying : krb5-workstation-1.10.-.el6.x86_64 /
Verifying : libselinux-2.0.-5.8.el6.x86_64 /
Verifying : libcom_err-1.41.-.el6.x86_64 /
Verifying : libselinux-python-2.0.-5.8.el6.x86_64 /
Verifying : e2fsprogs-libs-1.41.-.el6.x86_64 / 已安装:
autoconf.noarch :2.63-5.1.el6 automake.noarch :1.11.-.el6
cmake.x86_64 :2.8.12.2-.el6 gcc-c++.x86_64 :4.4.-.el6
libtool.x86_64 :2.2.-15.5.el6 ncurses-devel.x86_64 :5.7-4.20090207.el6
openssl-devel.x86_64 :1.0.1e-.el6 subversion.x86_64 :1.6.-.el6_7 作为依赖被安装:
cloog-ppl.x86_64 :0.15.-1.2.el6 cpp.x86_64 :4.4.-.el6
gcc.x86_64 :4.4.-.el6 keyutils-libs-devel.x86_64 :1.4-.el6
krb5-devel.x86_64 :1.10.-.el6 libcom_err-devel.x86_64 :1.41.-.el6
libkadm5.x86_64 :1.10.-.el6 libselinux-devel.x86_64 :2.0.-.el6
libsepol-devel.x86_64 :2.0.-.el6 libstdc++-devel.x86_64 :4.4.-.el6
mpfr.x86_64 :2.4.-.el6 perl-URI.noarch :1.40-.el6
ppl.x86_64 :0.10.-.el6 zlib-devel.x86_64 :1.2.-.el6 作为依赖被升级:
e2fsprogs.x86_64 :1.41.-.el6 e2fsprogs-libs.x86_64 :1.41.-.el6
krb5-libs.x86_64 :1.10.-.el6 krb5-workstation.x86_64 :1.10.-.el6
libcom_err.x86_64 :1.41.-.el6 libgcc.x86_64 :4.4.-.el6
libgomp.x86_64 :4.4.-.el6 libselinux.x86_64 :2.0.-.el6
libselinux-python.x86_64 :2.0.-.el6 libselinux-utils.x86_64 :2.0.-.el6
libss.x86_64 :1.41.-.el6 libstdc++.x86_64 :4.4.-.el6
openssl.x86_64 :1.0.1e-.el6 完毕!
[root@master soft]#
安装Maven
编译要求:Maven 3.0 or later
安装软件:apache-maven-3.0.5-bin.tar.gz
[root@hadoop1 soft]# ls
apache-maven-3.3.9-bin.tar.gz
[root@hadoop1 soft]# chmod 755 apache-maven-3.3.9-bin.tar.gz
[root@hadoop1 soft]# tar -zxvf apache-maven-3.3.9-bin.tar.gz
。。。
[root@hadoop1 soft]# mv apache-maven-3.3.9 /opt/
[root@hadoop1 soft]# vi /etc/profile
配置mvn的环境变量
export M2_HOME=/opt/apache-maven-3.3.
export PATH=$PATH:$M2_HOME/bin
测试
[root@hadoop1 soft]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /opt/apache-maven-3.3.9
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: /usr/local/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@hadoop1 soft]#
安装Findbugs
编译要求:Findbugs 1.3.9
安装软件:findbugs-3.0.1.tar.gz
[root@hadoop1 soft]# ls
findbugs-3.0.1.tar.gz
[root@hadoop1 soft]# chmod 755 findbugs-3.0.1.tar.gz
[root@hadoop1 soft]# tar -zxvf findbugs-3.0.1.tar.gz -C /opt
配置Findbugs环境变量
[root@hadoop1 soft]# vi /etc/profile
export FINDBUGS_HOME=/opt/findbugs-3.0.1
export PATH=$PATH:$FINDBUGS_HOME/bin
测试
[root@hadoop1 soft]# findbugs -version
3.0.1
[root@hadoop1 soft]#
安装ProtocolBuffer
编译要求:ProtocolBuffer 2.5.0
安装软件:protobuf-2.5.0.tar.gz,不建议用其它版本
[root@hadoop1 soft]# ls
protobuf-2.5.0.tar.gz
[root@hadoop1 soft]# chmod 755 protobuf-2.5.0.tar.gz
[root@hadoop1 soft]# tar -zxvf protobuf-2.5.0.tar.gz -C /opt
[root@hadoop1 soft]# cd /opt/protobuf-2.5.0/
[root@hadoop1 protobuf-2.5.0]# ./configure
[root@hadoop1 protobuf-2.5.0]# make
[root@hadoop1 protobuf-2.5.0]# make install
测试
[root@hadoop1 protobuf-2.5.0]# protoc --version
libprotoc 2.5.0
[root@hadoop1 protobuf-2.5.0]#
修改maven的配置文件,添加maven的下载源
[root@hadoop1 protobuf-2.5.0]# cd /opt/apache-maven-3.3.9/conf/
[root@hadoop1 conf]# vi settings.xml
在mirrors中添加alimaven的下载源
<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>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
安装Ant
[root@hadoop1 soft]# ls
apache-ant-1.9.-bin.tar.gz hadoop-2.7.-src
[root@hadoop1 soft]# tar -zxvf apache-ant-1.9.-bin.tar.gz -C /opt/
配置环境变量
[root@hadoop1 apache-ant-1.9.]# vi /etc/profile
#Ant
export ANT_HOME=/opt/apache-ant-1.9.
export PATH=$PATH:$ANT_HOME/bin
检测
[root@hadoop1 apache-ant-1.9.]# ant -version
Apache Ant(TM) version 1.9. compiled on April
[root@hadoop1 apache-ant-1.9.]#
安装Snappy
解压
[root@hadoop1 soft]# ls
hadoop-2.7.-src snappy-1.1..tar.gz
[root@hadoop1 soft]# tar -zxvf snappy-1.1..tar.gz -C /opt/
安装
[root@hadoop1 soft]# cd /opt/snappy-1.1./
[root@hadoop1 snappy-1.1.]# ./configure
[root@hadoop1 snappy-1.1.]# make
[root@hadoop1 snappy-1.1.]# make install
查看snappy文件库
[root@hadoop1 snappy-1.1.]# ls -lh /usr/local/lib | grep snappy
-rw-r--r-- root root 228K 3月 : libsnappy.a
-rwxr-xr-x root root 3月 : libsnappy.la
lrwxrwxrwx root root 3月 : libsnappy.so -> libsnappy.so.1.2.
lrwxrwxrwx root root 3月 : libsnappy.so. -> libsnappy.so.1.2.
-rwxr-xr-x root root 145K 3月 : libsnappy.so.1.2.
[root@hadoop1 snappy-1.1.]#
开始编译hadoop
[root@hadoop1 soft]# ls
[root@hadoop1 soft]# tar -zxvf hadoop-2.7.5-src.tar.gz
在编译之前防止java.lang.OutOfMemoryError:Java heap space堆栈问题,在centos系统中执行命令
[root@hadoop1 snappy-1.1.]# export MAVEN_OPTS="-Xms256m -Xmx512m"
进入源码包下,执行命令进行编译
[root@hadoop1 snappy-1.1.]# cd /soft/hadoop-2.7.-src/
[root@hadoop1 hadoop-2.7.-src]# mvn package -Pdist,native,docs -DskipTests -Dtar
如果中途编译失败,并且不要文档的话,请使用这个命令:
[root@master ~]# mvn clear package -Pdist,native -DskipTests -Dtar -Dsnappy.lib=/usr/local/lib -Dbundle.snappy -Drequire.openssl
编译成功之后,hadoop-2.7.5.tar.gz位于/soft/hadoop-2.7.5-src/hadoop-dist/target目录下,这是编译后文件夹的状态
至此,大功告成!!!