b. 安装编译所需依赖
$sudo apt-get install g++ autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev
c. 安装protobuf 2.5.0
$cd $HOME/protobuf2.5.0
$./configure --prefix=/usr
$sudo make
$sudo make check
$sudo make install
$ protoc --version
libprotoc 2.5.0
d. 安装maven
$ sudo apt-get install maven
e. 开始编译
$ cd ~
$ tar -xzvf Hadoop-2.2.0-src.tar.gz
$ cd hadoop-2.2.0-src/
$ mvn package -Pdist,native -DskipTests -Dtar
编译大概耗时约30分钟,编译完后的文件在 hadoop-2.2.0-src/hadoop-dist/target 路径中。如果发起的虚拟机都是相同操作系统,编译只需要在一台机器上执行。
验证编译结果:
yarn@hdp-server-01:~$ $HOME/hadoop-2.2.0/bin/hadoop version
Hadoop 2.2.0
Subversion Unknown -r Unknown
Compiled by yarn on 2013-11-05T06:41Z
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4
This command was run using /home/yarn/hadoop-2.2.0/share/hadoop/common/hadoop-common-2.2.0.jar
yarn@hdp-server-01:~$ file $HOME/hadoop-2.2.0/lib/native/*
/home/yarn/hadoop-2.2.0/lib/native/libhadoop.a: current ar archive
/home/yarn/hadoop-2.2.0/lib/native/libhadooppipes.a: current ar archive
/home/yarn/hadoop-2.2.0/lib/native/libhadoop.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0xaa74c9d23bfe750f160412e4465b14c88cf1c650, not stripped
/home/yarn/hadoop-2.2.0/lib/native/libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0xaa74c9d23bfe750f160412e4465b14c88cf1c650, not stripped
/home/yarn/hadoop-2.2.0/lib/native/libhadooputils.a: current ar archive
/home/yarn/hadoop-2.2.0/lib/native/libhdfs.a: current ar archive
/home/yarn/hadoop-2.2.0/lib/native/libhdfs.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x89671252f3c5fb7034425e80c9d31ea67da75c4d, not stripped
/home/yarn/hadoop-2.2.0/lib/native/libhdfs.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x89671252f3c5fb7034425e80c9d31ea67da75c4d, not stripped