今天来说说编译hadoop源代码的事情吧~
1、首先下载源代码
地址:http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.4.0/
2、加压tar包到指定目录:/home/hadoop/soft/hadoop
tar zxvf hadoop-2.4.0-src.tar.gz
3、Linux编译环境准备
- java环境准备
- maven环境
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZW5zb24xNjg1NQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
解压到指定目录:/home/hadoop/soft/
配置maven本地仓库,编辑maven下 conf/settings.xml文件
<localRepository>/home/hadoop/soft/repo</localRepository>
- ant环境
以上maven,JDK,ant的配置例如以下:
root用户以下编辑/etc/profile
命令例如以下:
vim /etc/profile
在此文件最后面加上下面内容
export JAVA_HOME=/usr/java/jdk1.7.0_60
export PATH="$JAVA_HOME/bin:$PATH" export MAVEN_HOME=/home/hadoop/soft/apache-maven-3.2.1
export PATH="$MAVEN_HOME/bin:$PATH" export ANT_HOME=/home/hadoop/soft/apache-ant-1.9.4
export PATH="$ANT_HOME/bin:$PATH" export HADOOP_PREFIX=/home/hadoop/soft/hadoop/hadoop-2.4.0
export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"
export PATH="$JAVA_HOME/:$HADOOP_PREFIX/bin:$PATH"
export HADOOP_PREFIX PATH CLASSPATH
- openssl库的安装
採用yum方式安装,yum配置參照:http://blog.csdn.net/enson16855/article/details/9140623
命令例如以下:root用户哦~
yum install openssl
- CMake安装
与openssl的安装一样,採用yum安装:
yum install cmake
- protobuf的安装
下载:
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
下载完毕解压:
tar zxvf protobuf-2.5.0.tar.gz
进入解压的目录中。运行下面命令:
sudo ./configure
sudo make
sudo make check
sudo make install
sudo ldconfig
验证:
4、编译hadoop2.4源代码
运行下面命令:
mvn package -Pdist -DskipTests -Dtar
进到~/hadoop-2.4.0-src/hadoop-dist/target目录中有:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZW5zb24xNjg1NQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">