摘自 http://www.aboutyun.com/thread-8130-1-1.html、http://www.dataguru.cn/forum.php?mod=viewthread&tid=189176</pre><p><span style="font-size:18px; word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun"><span style="word-wrap:break-word; font-weight:700">一、首先下载hadoop源码包</span></span></p><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">下载的方式还是比较多的</span><br style="word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px" /><span style="font-size:12px; word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun"><span style="word-wrap:break-word; font-weight:700">1.svn的方式</span><br style="word-wrap:break-word" /></span><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">svn下载首先需要安装SVN,如果想尝试使用svn,可以参考</span><a target=_blank target="_blank" href="http://www.aboutyun.com/thread-7982-1-1.html" style="word-wrap:break-word; color:rgb(51,102,153); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">源码管理、获取网络源码工具:TortoiseSVN使用手册</a><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">,hadoop的svn下载地址</span><a target=_blank target="_blank" href="http://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.4.0/" style="word-wrap:break-word; color:rgb(51,102,153); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">点此</a><br style="word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px" /><span style="font-size:12px; word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun"><span style="word-wrap:break-word; font-weight:700">2.压缩包的方式</span><br style="word-wrap:break-word" /></span><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">这里我们介绍一种压缩包的方式。</span><br style="word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px" /><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">首先我们登录官网:</span><br style="word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px" /><p><a target=_blank target="_blank" href="http://hadoop.apache.org/" style="word-wrap:break-word; color:rgb(51,102,153); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">http://hadoop.apache.org/</a><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">,我们找到下面链接,点进去下载即可。如果刚接触,不知道怎么下载,可以查看帖子</span><a target=_blank target="_blank" href="http://www.aboutyun.com/thread-7648-1-1.html" style="word-wrap:break-word; color:rgb(51,102,153); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">新手指导:hadoop官网介绍及如何下载hadoop(2.4)各个版本与查看hadoop API介绍</a><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px">,里面介绍的很详细。</span></p><p><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:14px; line-height:21px"><span style="word-wrap:break-word; font-weight:700; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; font-size:18px; line-height:27px">二、解压</span></span></p><p><span style="color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; line-height:21px"><span style="word-wrap:break-word; color:rgb(68,68,68); font-family:Tahoma,'Microsoft Yahei',Simsun; line-height:27px"></span></span></p><pre code_snippet_id="411193" snippet_file_name="blog_20140630_2_3347926" name="code" class="html">tar zxvf hadoop-2.4.0-src.tar.gz
1、jdk的安装
步骤下载压缩包、解压、配置环境变量 JDK需要下载1.7版本,1.8版本问题较多
tar zxvf jdk-7u51-linux-x64.tar.gz
配置环境变量: (etc/profile)
/usr/jdk1.7/bin
检验是否安装成功
java -version
2、maven的安装
下载3.2.2版本 http://maven.apache.org/download.cgi
解压,拷贝到 /usr/local目录中,并配置环境变量(etc/profile)
检验是否安装成功
mvn -version
3.protobuf的安装
下载https://code.google.com/p/protobuf/,解压到 /usr/local
然后进入protobuf-2.5.0文件夹,进行如下操作:
$ sudo ./configure $ sudo make $ sudo make check $ sudo make install $ sudo ldconfig注:如执行 configure报错,请检查是否为缺乏gcc编译环境造成,需安装
yum install gcc-c++安装成功后,重新执行make语句,完成后进行验证
protoc --version (注:有两个-符号)
4.安装openssl库
yum install openssl-devel需要安装开发版本
5.CMake安装
sudo yum install cmake5.zlib安装
yum install zlib-devel6.ant安装
ant -version检验安装是否正确。
四、编译hadoop2.4
上面准备工作已经做的差不多了,我们终于可以开始,记得进入src文件夹下,输入下面命令
mvn package -Pdist,native -DskipTests -Dtar