1、解压hadoop源代码
tar -zxvf hadoop-2.8.1-src.tar.gz

2、进入hadoop-s.8.1-src

首先pom文件,pom是项目的依赖管理文件,jar包。大家可以简单看一下需要下载哪些jar包。
3、主要是查看BUILDING.txt文件

这是编译hadoop需要的一些软件版本要求,我,我们挨个看一下符不符合要求;
3.1我使用的是centos6.x,符合“Unix System”要求。
3.2 查看一下jdk版本

jdk1.8.8_171符合要求“1.7+”。
3.3查看maven版本

maven版本3.3.9符合“3.0 or later”。
3.4

findbugs未安装,安装一下(我已经事先把文件发送到服务器上):
解压 unzip findbugs-1.3.9.zip
配置环境变量
vi /etc/profile
配置路径:

生效:source /etc/profile

findbugs版本1.3.9符合要求。
3.5
解压protobuf,用户组,跟创建用户有问题

改变创建用户及用户组


看一下有些底层基础软件有没有安装,精简版的可能会没有,就会导致问题
yum install gcc gcc-c++ make cmake
protobuf解压后并不能直接使用而是需要预编译:
./configure --prefix=/usr/local/protobuf

make && make install
预编译到“/usr/local/protobuf”目录下
/usr/local 目录下创建了protobuf目录。
配置环境变量:

检验版本号:
protoc --version

符合要求。
3.6 others
使用yum统一安装
yum -y install openssl openssl-devel svn ncurses-devel zlib-devel libtool
yum install -y snappy snappy-devel bzip2 bzip2-devel lzo lzo-devel lzop autoconf automake
以上就是编译前的文件安装
====================================================================
4.编译
再次打开hadoop 文件夹中BUILDING.txt文件;
找到如下地方:

我们使用第二条然后去掉docs,clean一下
命令:mvn clean package -Pdist,native -DskipTests -Dtar
编译好的tar包
/opt/software/hadoop-2.8.1-src/hadoop-dist/target/hadoop-2.8.1.tar.gz;
至此编译完成!!!
注意:
1、有时候编译过程中会出现下载某个包的时间太久,这是由于连接网站的过程中会出现假死,
此时按ctrl+c,重新运行编译命令。
2、如果出现缺少了某个文件的情况,则要先清理maven(使用命令 mvn clean) 再重新编译。
网友评论