1、安装jdk1.7,并配置环境变量
2、安装其他基础库
[root@hadoop0cdh]# yum install g++ autoconf automake libtool make cmake zlib1g-dev pkg-config libssl-dev
(1). 如果是Debian或CentOs 安装
# yum install g++ autoconf automake libtool make cmake zlib1g-dev pkg-config libssl-dev
# yum install openssh-clients
# yum install openssh-server
========编译源码=========
yum install openssl
yum install openssl-devel
(2). 安装protobuf
下载地址:下载最新的安装包,当前最新的安装包为 protobuf-2.5.0
https://code.google.com/p/protobuf/downloads/list
# tar -xzvf protobuf-2.5.0.tar.gz
# cd probuf-2.5.0
# ./configure ; make ; make check; make install
# protoc --version
libprotoc 2.5.0
3. 安装maven
Maven是一个软件项目管理及自动构建工具,用于组件的编译和构建。
(1). 首先到Maven官网(http://maven.apache.org/download.cgi),
下载最新的bin包(apache-maven-3.2.1-bin.tar.gz)。完成后解压并将目录移动到/usr/local/apache-maven
# tar -xzvf apache-maven-3.2.1-bin.tar.gz
# cp -r apache-maven-3.2.1 /usr/local/apache-maven-3.2.1
(2). 编辑/etc/profile,配置环境变量
MAVEN_HOME=/usr/local/apache-maven-3.2.1
PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME PATH
(3). 保存环境变量
# source /etc/profile
(4). 测试安装成功与否
$ echo $MAVEN_HOME
/usr/local/apache-maven/apache-maven-3.2.1
$ mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T01:37:52+08:00)
Maven home: /usr/local/apache-maven/apache-maven-3.2.1
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_51/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.18-194.el5", arch: "amd64", family: "unix"
(5). 修改maven配置
由于maven国外服务器可能连不上,先给maven配置一下国内镜像,在maven目录下,conf/settings.xml,
在里添加,原本的不要动, 同样, 在内新添加
# vim $MAVEN_HOME/conf/settings.xml
4. 编译安装Hadoop
(1). 首先官方下载hadoop源码
# tar -xzvf hadoop-2.5.2-src.tar.gz
# cd hadoop-2.5.2-src
(2). 编译hadoop源码,见BUILDING.txt
# mvn package -Pdist,native -DskipTests -Dtar
[root@hadoop0hadoop-2.5.2-src]# mvn package -Pdist,native -DskipTests -Dtar
main:
[exec] $ tar cf hadoop-2.5.2.tar hadoop-2.5.2
[exec] $ gzip -f hadoop-2.5.2.tar
[exec]
[exec] Hadoop dist tar available at: /home/jit/hadoop-2.5.2-src/hadoop-dist/target/hadoop-2.5.2.tar.gz
[exec]
[INFO] Executed tasks
[INFO]
[INFO] --- maven-javadoc-plugin:2.8.1:jar (module-javadocs) @ hadoop-dist ---
[INFO] Building jar: /home/jit/hadoop-2.5.2-src/hadoop-dist/target/hadoop-dist-2.5.2-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Hadoop Main ................................ SUCCESS [6:18.375s]
[INFO] Apache Hadoop Project POM ......................... SUCCESS [2:49.482s]
[INFO] Apache Hadoop Annotations ......................... SUCCESS [1:21.699s]
[INFO] Apache Hadoop Assemblies .......................... SUCCESS [0.317s]
[INFO] Apache Hadoop Project Dist POM .................... SUCCESS [47.975s]
[INFO] Apache Hadoop Maven Plugins ....................... SUCCESS [2:48.379s]
[INFO] Apache Hadoop MiniKDC ............................. SUCCESS [3:44.819s]
[INFO] Apache Hadoop Auth ................................ SUCCESS [40.856s]
[INFO] Apache Hadoop Auth Examples ....................... SUCCESS [20.129s]
[INFO] Apache Hadoop Common .............................. SUCCESS [12:46.117s]
[INFO] Apache Hadoop NFS ................................. SUCCESS [7.586s]
[INFO] Apache Hadoop Common Project ...................... SUCCESS [0.091s]
[INFO] Apache Hadoop HDFS ................................ SUCCESS [8:58.964s]
[INFO] Apache Hadoop HttpFS .............................. SUCCESS [1:10.984s]
[INFO] Apache Hadoop HDFS BookKeeper Journal ............. SUCCESS [1:23.640s]
[INFO] Apache Hadoop HDFS-NFS ............................ SUCCESS [7.357s]
[INFO] Apache Hadoop HDFS Project ........................ SUCCESS [0.043s]
[INFO] hadoop-yarn ....................................... SUCCESS [0.059s]
[INFO] hadoop-yarn-api ................................... SUCCESS [2:07.007s]
[INFO] hadoop-yarn-common ................................ SUCCESS [1:17.938s]
[INFO] hadoop-yarn-server ................................ SUCCESS [0.097s]
[INFO] hadoop-yarn-server-common ......................... SUCCESS [26.052s]
[INFO] hadoop-yarn-server-nodemanager .................... SUCCESS [1:13.852s]
[INFO] hadoop-yarn-server-web-proxy ...................... SUCCESS [3.312s]
[INFO] hadoop-yarn-server-applicationhistoryservice ...... SUCCESS [5.614s]
[INFO] hadoop-yarn-server-resourcemanager ................ SUCCESS [15.575s]
[INFO] hadoop-yarn-server-tests .......................... SUCCESS [0.668s]
[INFO] hadoop-yarn-client ................................ SUCCESS [4.992s]
[INFO] hadoop-yarn-applications .......................... SUCCESS [0.088s]
[INFO] hadoop-yarn-applications-distributedshell ......... SUCCESS [2.776s]
[INFO] hadoop-yarn-applications-unmanaged-am-launcher .... SUCCESS [1.838s]
[INFO] hadoop-yarn-site .................................. SUCCESS [0.068s]
[INFO] hadoop-yarn-project ............................... SUCCESS [6.152s]
[INFO] hadoop-mapreduce-client ........................... SUCCESS [0.071s]
[INFO] hadoop-mapreduce-client-core ...................... SUCCESS [39.780s]
[INFO] hadoop-mapreduce-client-common .................... SUCCESS [29.196s]
[INFO] hadoop-mapreduce-client-shuffle ................... SUCCESS [9.253s]
[INFO] hadoop-mapreduce-client-app ....................... SUCCESS [20.963s]
[INFO] hadoop-mapreduce-client-hs ........................ SUCCESS [12.344s]
[INFO] hadoop-mapreduce-client-jobclient ................. SUCCESS [17.145s]
[INFO] hadoop-mapreduce-client-hs-plugins ................ SUCCESS [1.957s]
[INFO] Apache Hadoop MapReduce Examples .................. SUCCESS [12.555s]
[INFO] hadoop-mapreduce .................................. SUCCESS [6.724s]
[INFO] Apache Hadoop MapReduce Streaming ................. SUCCESS [9.407s]
[INFO] Apache Hadoop Distributed Copy .................... SUCCESS [1:02.991s]
[INFO] Apache Hadoop Archives ............................ SUCCESS [2.343s]
[INFO] Apache Hadoop Rumen ............................... SUCCESS [13.471s]
[INFO] Apache Hadoop Gridmix ............................. SUCCESS [4.361s]
[INFO] Apache Hadoop Data Join ........................... SUCCESS [2.644s]
[INFO] Apache Hadoop Extras .............................. SUCCESS [11.507s]
[INFO] Apache Hadoop Pipes ............................... SUCCESS [8.624s]
[INFO] Apache Hadoop OpenStack support ................... SUCCESS [8.665s]
[INFO] Apache Hadoop Client .............................. SUCCESS [14.059s]
[INFO] Apache Hadoop Mini-Cluster ........................ SUCCESS [0.096s]
[INFO] Apache Hadoop Scheduler Load Simulator ............ SUCCESS [13.475s]
[INFO] Apache Hadoop Tools Dist .......................... SUCCESS [9.339s]
[INFO] Apache Hadoop Tools ............................... SUCCESS [2.331s]
[INFO] Apache Hadoop Distribution ........................ SUCCESS [41.499s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 57:52.573s
[INFO] Finished at: Thu Feb 18 13:49:53 CST 2016
[INFO] Final Memory: 143M/478M
[INFO] ------------------------------------------------------------------------
[root@hadoop0hadoop-2.5.2-src]#
[root@hadoop0hadoop-2.5.2-src]# pwd
/home/jit/hadoop-2.5.2-src
[root@hadoop0hadoop-2.5.2-src]# cd hadoop-dist
[root@hadoop0hadoop-dist]# ll
总用量 12
-rw-r--r--. 1 10021 10021 6826 11月 15 2014 pom.xml
drwxr-xr-x. 7 root root 4096 2月 18 13:49 target
[root@hadoop0hadoop-dist]# cd target
[root@hadoop0target]# ll
总用量 390176
drwxr-xr-x. 2 root root 4096 2月 18 13:49 antrun
-rw-r--r--. 1 root root 1767 2月 18 13:49 dist-layout-stitching.sh
-rw-r--r--. 1 root root 639 2月 18 13:49 dist-tar-stitching.sh
drwxr-xr-x. 9 root root 4096 2月 18 13:49 hadoop-2.5.2
-rw-r--r--. 1 root root 132935327 2月 18 13:49 hadoop-2.5.2.tar.gz
-rw-r--r--. 1 root root 2771 2月 18 13:49 hadoop-dist-2.5.2.jar
-rw-r--r--. 1 root root 266565313 2月 18 13:49 hadoop-dist-2.5.2-javadoc.jar
drwxr-xr-x. 2 root root 4096 2月 18 13:49 javadoc-bundle-options
drwxr-xr-x. 2 root root 4096 2月 18 13:49 maven-archiver
drwxr-xr-x. 2 root root 4096 2月 18 13:49 test-dir
同样在刚刚进行编译的那个目录下,有一个Hadoop-dist文件夹,进入里面的target文件夹,然后就可以看到编译成功64位的hadoop文件,解压后的在 hadoop-2.5.2 这个文件夹中,同时还生成了一个压缩包:hadoop-2.5.2-tar.gz 这个压缩包可以拷贝到别的机器上进行安装