本文主要记录Hadoop2.x在Ubuntu 12.04下编译源码的主要步骤和注意点:
[一]、基础环境
- Ubuntu 12.04 LTS 64 位
- Hadoop2.2.0
- Java version: 1.7.0_55
- Apache Maven 3.2.1
[二]、软件配置
1、更新apt 源
vi /et/apt/sources.list
,在文件末增加如下国内访问比较快的源:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 163 源 deb http://mirrors.163.com/ubuntu/ precise-updates main restricted deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted deb http://mirrors.163.com/ubuntu/ precise universe deb-src http://mirrors.163.com/ubuntu/ precise universe deb http://mirrors.163.com/ubuntu/ precise-updates universe deb-src http://mirrors.163.com/ubuntu/ precise-updates universe deb http://mirrors.163.com/ubuntu/ precise multiverse deb-src http://mirrors.163.com/ubuntu/ precise multiverse deb http://mirrors.163.com/ubuntu/ precise-updates multiverse deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse # 中科大 deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted deb http://mirrors.ustc.edu.cn/ubuntu/ precise universe deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise universe deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates universe deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates universe deb http://mirrors.ustc.edu.cn/ubuntu/ precise multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse # added by micmiu.com |
保存修改后执行:
1 2 |
sudo apt-get update sudo apt-get upgrade |
2、安装编译需要的第三方软件:
1 2 |
#一次安装全部依赖的软件 sudo apt-get install g++ autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev |
3、编译安装:protobuf
去官网下载:http://code.google.com/p/protobuf/downloads/list (目前 2.5.0版本),然后解压编译安装:
1 2 3 4 5 |
tar xzf protobuf-2.5.0.tar.gz cd protobuf-2.5.0/ ./configure --prefix=/usr make check make install |
安装完成后验证下:
1 2 |
micmiu@ubuntu:~$ protoc --version libprotoc 2.5.0 |
ps:默认情况下,protobuf 包会被安装在/usr/local路径下。但是,在某些系统平台上(如Ubuntu 12),/usr/local/lib 路径并不包含在LD_LIBRARY_PATH 中。当然你亦可手动添加,但是一般的做法是configure命令指定参数 prefix: ./configure --prefix=/usr
[三]、Hadoop编译
下载源码:
1 |
svn co https://svn.apache.org/repos/asf/hadoop/common/tags/release-2.2.0 hadoop-release-2.2.0 |
ps: hadoop2.2.0的源码有个bug :修改 <源码跟目录>/hadoop-common-project/hadoop-auth/pom.xml中添加如下依赖:
1 2 3 4 5 |
<dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-util</artifactId> <scope>test</scope> </dependency> |
然后执行编译命令:
1 2 |
cd hadoop-release-2.2.0 mvn package -Pdist,native -DskipTests -Dtar |
编译成功后,可以在目录 hadoop-dist/target 下找到相关的发布包。
—————– EOF @Michael Sun —————–
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
本文链接地址: http://www.micmiu.com/bigdata/hadoop/hadoop-2x-ubuntu-build/
0 条评论。