前期准备工作
-
CentOS联网
-
使用root用户编译
-
jar包准备(hadoop源码、JDK7 、 maven、 ant 、protobuf)
(1)hadoop-2.7.2-src.tar.gz
(2)jdk-7u79-linux-x64.gz
(3)apache-ant-1.9.9-bin.tar.gz
(4)apache-maven-3.0.5-bin.tar.gz
(5)protobuf-2.5.0.tar.gz -
Maven解压、配置 MAVEN_HOME和PATH
-
ant解压、配置 ANT _HOME和PATH。
[root@hadoop101 software]# tar -zxvf apache-ant-1.9.9-bin.tar.gz -C /opt/module/ [root@hadoop101 apache-ant-1.9.9]# vi /etc/profile #ANT_HOME export ANT_HOME=/opt/module/apache-ant-1.9.9 export PATH=$PATH:$ANT_HOME/bin [root@hadoop101 software]#source /etc/profile 验证命令:ant -version
-
安装 glibc-headers 和 g++ 命令如下:
[root@hadoop101 apache-ant-1.9.9]# yum install glibc-headers [root@hadoop101 apache-ant-1.9.9]# yum install gcc-c++
-
安装make和cmake
[root@hadoop101 apache-ant-1.9.9]# yum install make [root@hadoop101 apache-ant-1.9.9]# yum install cmake
-
解压protobuf ,进入到解压后protobuf主目录,/opt/module/protobuf-2.5.0
然后相继执行命令: [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
-
安装openssl库
[root@hadoop101 software]#yum install openssl-devel
-
安装 ncurses-devel库:
[root@hadoop101 software]#yum install ncurses-devel到此,编译工具安装基本完成。
编译源码
-
解压源码到/opt/tools目录
[root@hadoop101 software]# tar -zxvf hadoop-2.7.2-src.tar.gz -C /opt/ 进入到hadoop源码主目录 [root@hadoop101 hadoop-2.7.2-src]# pwd /opt/hadoop-2.7.2-src
-
通过maven执行编译命令
[root@hadoop101 hadoop-2.7.2-src]#mvn package -Pdist,native -DskipTests -Dtar 等待时间30分钟左右,最终成功是全部SUCCESS。
-
成功的64位hadoop包在/opt/hadoop-2.7.2-src/hadoop-dist/target下。
[root@hadoop101 target]# pwd /opt/hadoop-2.7.2-src/hadoop-dist/target