环境及工具:
CentOS7.5
jdk-8u131-linux-x64.tar.gz
apache-ant-1.9.9-bin.tar.gz
apache-maven-3.0.5-bin.tar.gz
protobuf-2.5.0.tar.gz
hadoop-2.6.5-src.tar.gz
编译环境要求:
[root@hadoop106 app-software]# tar -zxvf hadoop-2.6.5-src.tar.gz -C /app/
[root@hadoop106 app-software]# cd /app/hadoop-2.6.5-src
[root@hadoop106 hadoop-2.6.5-src]# pwd
/app/hadoop-2.6.5-src
[root@hadoop106 hadoop-2.6.5-src]# cat BUILDING.txt
Build instructions for Hadoop
Requirements:
- Unix System
- JDK 1.6+
- 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 )
- Internet connection for first build (to fetch all Maven and Hadoop dependencies)
安装JDK
[root@hadoop106 app-software]# pwd
/app-software
[root@hadoop106 app-software]# tar -zxvf jdk-8u131-linux-x64.tar.gz -C /app/
[root@hadoop106 jdk1.8.0_131]# pwd
/app/jdk1.8.0_131
[root@hadoop106 jdk1.8.0_131]# vi /etc/profile
## JAVA_HOME
export JAVA_HOME=/app/jdk1.8.0_131
export PATH=$PATH:$JAVA_HOME/bin
[root@hadoop106 jdk1.8.0_131]# source /etc/profile
[root@hadoop106 jdk1.8.0_131]# java -version
安装MAVEN
[root@hadoop106 app-software]# tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /app
[root@hadoop106 conf]# pwd
/app/apache-maven-3.0.5/conf
[root@hadoop106 conf]# vi settings.xml
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
[root@hadoop106 apache-maven-3.0.5]# pwd
/app/apache-maven-3.0.5
[root@hadoop106 apache-maven-3.0.5]# vi /etc/profile
## MAVEN_HOME
export MAVEN_HOME=/app/apache-maven-3.0.5
export PATH=$PATH:$MAVEN_HOME/bin
[root@hadoop106 apache-maven-3.0.5]# source /etc/profile
[root@hadoop106 apache-maven-3.0.5]# mvn -version
安装ANT
[root@hadoop106 app-software]# tar -zxvf apache-ant-1.9.9-bin.tar.gz -C /app
[root@hadoop106 apache-ant-1.9.9]# pwd
/app/apache-ant-1.9.9
[root@hadoop106 apache-ant-1.9.9]# vi /etc/profile
## ANT_HOME
export ANT_HOME=/app/apache-ant-1.9.9
export PATH=$PATH:$ANT_HOME/bin
[root@hadoop106 apache-ant-1.9.9]# source /etc/profile
[root@hadoop106 apache-ant-1.9.9]# ant -version
[root@hadoop106 apache-ant-1.9.9]# yum install glibc-headers
[root@hadoop106 apache-ant-1.9.9]# yum install gcc-c++
[root@hadoop106 apache-ant-1.9.9]# yum install make
[root@hadoop106 apache-ant-1.9.9]# yum install cmake
安装PROTOBUF
[root@hadoop106 app-software]# tar -zxvf protobuf-2.5.0.tar.gz -C /app
[root@hadoop106 protobuf-2.5.0]# pwd
/app/protobuf-2.5.0
[root@hadoop106 protobuf-2.5.0]# ./configure
[root@hadoop106 protobuf-2.5.0]# make
[root@hadoop106 protobuf-2.5.0]# make check
[root@hadoop106 protobuf-2.5.0]# make install
[root@hadoop106 protobuf-2.5.0]# ldconfig
[root@hadoop106 protobuf-2.5.0]# vi /etc/profile
## LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/app/protobuf-2.5.0
export PATH=$PATH:$LD_LIBRARY_PATH
[root@hadoop106 protobuf-2.5.0]# protoc --version
libprotoc 2.5.0
安装库
[root@hadoop106 protobuf-2.5.0]# yum install openssl-devel
[root@hadoop106 protobuf-2.5.0]# yum install ncurses-devel
[root@hadoop106 hadoop-2.6.5-src]# pwd
/app/hadoop-2.6.5-src
[root@hadoop106 hadoop-2.6.5-src]# mvn package -Pdist,native -DskipTests -Dtar
【报错】
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin…
[root@hadoop106 hadoop-2.6.5-src]# mvn clean package -Pdist,native -DskipTests -Dtar -Dmaven.javadoc.skip=true
【等待一段时间】
编译成功后,hadoop包在hadoop-dist的target下
**:用root编译,减少文件夹权限出现问题