1. 安装编译依赖类库
sudo apt-get install gcc
sudo apt-get install build-essential
sudo apt-get install libssl-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libglib2.0-dev
2. 安装jdk
http://openjdk.java.net/install
sudo apt-get install openjdk-7-jdk
sudo vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
source /etc/profile
java -version
3. 安装maven
http://maven.apache.org/download.cgi
tar zxvf apache-maven-3.1.1-bin.tar.gz
sudo mv apache-maven-3.1.1 /usr/local/
sudo vim /etc/profile
export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
source /etc/profile
mvn --version
4. 安装cmake
sudo apt-get install cmake
cmake --version
5 安装ProtocolBuffer 2.5.0(详细见上篇,这里简略描述过程)
https://code.google.com/p/protobuf/
https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
tar zxvf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0/
./configure
make
sudo make install
sudo ldconfig
6. 下载hadoop最新源代码
http://hadoop.apache.org/version_control.html
sudo apt-get install subversion
svn checkout http://svn.apache.org/repos/asf/hadoop/common/trunk/
7. 编译hadoop,这不很慢。。。。。。。。。。
进入下载好的hadoop源代码目录
mvn package -Pdist -Pnative -Dtar -DskipTests
附常见错误:
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
安装build-essential
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-hdfs: An Ant BuildException has occured: exec returned: 1 -> [Help 1]
安装libglib2.0-dev
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-pipes: An Ant BuildException has occured: exec returned: 1 -> [Help 1]
安装libssl-dev
8.结果
进入hadoop目录的hadoop-dist/target会发现很多包,其中有hadoop-2.2.0.tar.gz,这就是编译好的包,其他编译生成的就不清楚是什么了,日后再完善。