一直用的这个版本,时间久了,重新拿出来编译一下,有些坑,记录一下,各个版本之间的版本要求可能不一样,比如jdk......
BUILDING.txt
* Unix System
* JDK 1.6+ (hadoop-2.6.4不能用jdk1.8的,编译会出错,亲测)
* 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)
mvn -v
[zcy@master ~]$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
protoc --version
[zcy@master ~]$ protoc --version
libprotoc 2.5.0
make -version
[zcy@master ~]$ make -version
GNU Make 3.81
openssl version
[zcy@master ~]$ openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
1.yum安装(来源于网络,都先装上吧)
sudo yum -y install svn
sudo yum -y install ncurses-devel
sudo yum -y install gcc*
sudo yum -y install lzo-devel
sudo yum -y install zlib-devel
sudo yum -y install autoconf
sudo yum -y install automake
sudo yum -y install libtool
sudo yum -y install cmake
sudo yum -y install openssl
2.安装 protobuf(不安装,编译将无法完成)
hadoop使用protocol buffer进行通信,需要下载和安装protobuf-2.5.0.tar.gz;由于官网已经无法下载了,
可以到百度云盘下载http://pan.baidu.com/s/1eSrdvNG
编译安装 protobuf
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
将protobuf配置到环境里面去
sudo nano /etc/profile
export LD_LIBRARY_PATH=/usr/protobuf-2.5.0
protoc --version
libprotoc 2.5.0
3.添加maven的环境(最低3.0)
export MAVEN_HOME=/usr/apache-maven-3.5.0
export PATH=$PATH:$MAVEN_HOME/bin
3.先调整mvn的内存
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m" (此条命令来源于spark官网.....)
4.编译hadoop
mvn package -Pdist,native -DskipTests -Dtar (命令来源于./hadoop-2.6.4-src/BUILDING.txt)
最后看到结果如下,成功
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25:51 min
[INFO] Finished at: 2017-07-18T23:50:19+08:00
[INFO] Final Memory: 210M/861M
最后这个打包的结果在
/hadoop-2.6.4-src/hadoop-dist/target/目录下
-rw-rw-r-- 1 zcy zcy 180841120 7月 18 23:49 hadoop-2.6.4.tar.gz