CentOS6.5编译安装Hadoop2

分类:CentOS教程 阅读:62404 次

前言

CentOS6.5编译安装Hadoop2

环境

操作系统:CentOS_6.5_64bit

  1. [root@masterconf]#cat/proc/version;lsb_release-a
  2. Linuxversion2.6.32-431.5.1.el6.x86_64(mockbuild@c6b10.bsys.dev.centos.org)(gccversion4.4.720120313(RedHat4.4.7-4)(GCC))#1SMPWedFeb1200:41:43UTC2014
  3. LSBVersion::base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
  4. DistributorID:CentOS
  5. Description:CentOSrelease6.5(Final)
  6. Release:6.5
  7. Codename:Final

编译Hadoop版本:hadoop-2.2.0

准备

  1. [root@master~]#yum-yinstalljava-1.7.0-openjdkjava-1.7.0-openjdk-develldapjdk
  1. [root@master~]#ll/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/
  2. 总用量216
  3. -r--r--r--1rootroot15031月1420:59ASSEMBLY_EXCEPTION
  4. drwxr-xr-x2rootroot40963月1103:33bin
  5. drwxr-xr-x3rootroot40963月1103:33include
  6. drwxr-xr-x4rootroot40963月1103:33jre
  7. drwxr-xr-x3rootroot40963月1103:33lib
  8. -r--r--r--1rootroot192631月1420:59LICENSE
  9. drwxr-xr-x2rootroot40963月1103:33tapset
  10. -r--r--r--1rootroot1722521月1420:59THIRD_PARTY_README
查看java版本。
  1. [root@master~]#java-version
  2. javaversion"1.7.0_51"
  3. OpenJDKRuntimeEnvironment(rhel-2.4.4.1.el6_5-x86_64u51-b02)
  4. OpenJDK64-BitServerVM(build24.45-b08,mixedmode)

2. 安装maven(官方网站地址:http://maven.apache.org/)

Apache Maven,是一个软件(特别是Java软件)项目管理及自动构建工具,由Apache软件基金会所提供。基于项目对象模型(缩写:POM)概念,Maven利用一个中央信息片断能管理一个项目的构建、报告和文档等步骤。曾是Jakarta项目的子项目,现为独立Apache项目。

yum安装maven

  1. [root@mastermaven]#yuminstallapache-maven.noarch
查看maven版本
  1. [root@mastermaven]#mvn-version
  2. ApacheMaven3.2.1(ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9;2014-02-14T12:37:52-05:00)
  3. Mavenhome:/usr/share/apache-maven
  4. Javaversion:1.7.0_51,vendor:OracleCorporation
  5. Javahome:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/jre
  6. Defaultlocale:zh_CN,platformencoding:UTF-8
  7. OSname:"linux",version:"2.6.32-431.5.1.el6.x86_64",arch:"amd64",family:"unix"

下载安装maven(下载地址:http://maven.apache.org/download.cgi)apache-maven-3.2.1-bin.tar.gz

解压

  1. [root@master~]#tar-zxvfapache-maven-3.2.1-bin.tar.gz
  1. [root@master~]#cdapache-maven-3.2.1
  2. [root@masterapache-maven-3.2.1]#ll
  3. 总用量40
  4. drwxr-xr-x2rootroot40963月1802:23bin
  5. drwxr-xr-x2rootroot40963月1802:23boot
  6. drwxr-xr-x3rootroot40962月1412:34conf
  7. drwxr-xr-x3rootroot40963月1802:23lib
  8. -rw-r--r--1rootroot148652月1412:40LICENSE
  9. -rw-r--r--1rootroot1822月1412:39NOTICE
  10. -rw-r--r--1rootroot25132月1412:34README.txt
  1. [root@master~]#cp-rapache-maven-3.2.1/usr/local/
  2. [root@master~]#cd/usr/local/apache-maven-3.2.1/
  3. [root@masterapache-maven-3.2.1]#ll
  4. 总用量40
  5. drwxr-xr-x2rootroot40963月1802:24bin
  6. drwxr-xr-x2rootroot40963月1802:24boot
  7. drwxr-xr-x3rootroot40963月1802:24conf
  8. drwxr-xr-x3rootroot40963月1802:24lib
  9. -rw-r--r--1rootroot148653月1802:24LICENSE
  10. -rw-r--r--1rootroot1823月1802:24NOTICE
  11. -rw-r--r--1rootroot25133月1802:24README.txt
  12. [root@masterapache-maven-3.2.1]#
将MAVEN_HOME加入环境变量中。
  1. [root@masterapache-maven-3.2.1]#vim/etc/profile

在/etc/profile的最后一行加入如下。

  1. exportMAVEN_HOME=/usr/local/apache-maven-3.2.1
  2. exportPATH=.:$MAVEN_HOME/bin:$PATH
保存退出。

更新并查看maven版本。

  1. [root@masterapache-maven-3.2.1]#source/etc/profile
  2. [root@masterapache-maven-3.2.1]#mvn--version
  3. ApacheMaven3.2.1(ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9;2014-02-14T12:37:52-05:00)
  4. Mavenhome:/usr/local/apache-maven-3.2.1
  5. Javaversion:1.7.0_51,vendor:OracleCorporation
  6. Javahome:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/jre
  7. Defaultlocale:zh_CN,platformencoding:UTF-8
  8. OSname:"linux",version:"2.6.32-431.5.1.el6.x86_64",arch:"amd64",family:"unix"

3. 安装protobuf(官方网站地址:https://code.google.com/p/protobuf/)

  1. [root@master~]#yuminstallgccgcc-c++make
  1. [root@master~]#tar-zxvfprotobuf-2.5.0.tar.gz
  2. [root@master~]#cdprotobuf-2.5.0
  3. [root@masterprotobuf-2.5.0]#ll
  4. 总用量1212
  5. -rw-r--r--11099655000369762月262013aclocal.m4
  6. -rwxr-xr--1109965500015192月262013autogen.sh
  7. -rw-r--r--11099655000253122月262013CHANGES.txt
  8. -rwxr-xr--11099655000448262月262013config.guess
  9. -rw-r--r--1109965500037092月262013config.h.in
  10. -rwxr-xr--11099655000354542月262013config.sub
  11. -rwxr-xr--110996550005991502月262013configure
  12. -rw-r--r--1109965500048292月262013configure.ac
  13. -rw-r--r--1109965500035272月262013CONTRIBUTORS.txt
  14. -rw-r--r--1109965500017322月262013COPYING.txt
  15. -rwxr-xr--11099655000203342月262013depcomp
  16. drwxr-xr-x2109965500040962月262013editors
  17. drwxr-xr-x2109965500040962月262013examples
  18. -rwxr-xr--1109965500011052月262013generate_descriptor_proto.sh
  19. drwxr-xr-x15109965500040962月262013gtest
  20. -rwxr-xr--11099655000139982月262013install-sh
  21. -rw-r--r--1109965500095372月262013INSTALL.txt
  22. drwxr-xr-x3109965500040962月262013java
  23. -rw-r--r--110996550002836802月262013ltmain.sh
  24. drwxr-xr-x2109965500040962月262013m4
  25. -rw-r--r--11099655000151892月262013Makefile.am
  26. -rw-r--r--11099655000417422月262013Makefile.in
  27. -rwxr-xr--11099655000103462月262013missing
  28. -rw-r--r--110996550004082月262013protobuf-lite.pc.in
  29. -rw-r--r--110996550004292月262013protobuf.pc.in
  30. drwxr-xr-x3109965500040962月262013python
  31. -rw-r--r--1109965500053122月262013README.txt
  32. drwxr-xr-x4109965500040962月262013src
  33. drwxr-xr-x2109965500040962月262013vsprojects
  34. [root@masterprotobuf-2.5.0]#./configure--prefix=/usr/local/protoc/
  35. [root@masterprotobuf-2.5.0]#make&&makeinstall

安装完成后,将protoc写入环境变量。
  1. [root@masterprotobuf-2.5.0]#vim/etc/profile
  1. exportPROTOC_HOME=/usr/local/protoc
  2. exportPATH=.:$PROTOC_HOME/bin:$PATH
更新并查看protobuf版本。
  1. [root@masterprotobuf-2.5.0]#source/etc/profile
  2. [root@masterprotobuf-2.5.0]#protoc--version
  3. libprotoc2.5.0

4. 安装其他依赖

  1. [root@masterprotobuf-2.5.0]#yuminstallcmakeopenssl-develncurses-devel<spanstyle="font-size:18px;">
  2. </span>

编译安装

  1. [root@masterhadoop]#tar-zxvfhadoop-2.2.0-src.tar.gz
  1. [root@masterhadoop]#cdhadoop-2.2.0-src
  2. root@masterhadoop-2.2.0-src]#ll
  3. 总用量108
  4. -rw-r--r--167974users996810月701:53BUILDING.txt
  5. drwxr-xr-x267974users409610月702:45dev-support
  6. drwxr-xr-x367974users409610月702:45hadoop-assemblies
  7. drwxr-xr-x267974users409610月702:45hadoop-client
  8. drwxr-xr-x867974users409610月702:45hadoop-common-project
  9. drwxr-xr-x267974users409610月702:45hadoop-dist
  10. drwxr-xr-x667974users409610月702:45hadoop-hdfs-project
  11. drwxr-xr-x1067974users409610月702:45hadoop-mapreduce-project
  12. drwxr-xr-x367974users409610月702:45hadoop-maven-plugins
  1. [root@masterhadoop-2.2.0-src]#cdhadoop-common-project/hadoop-auth
  2. [root@masterhadoop-auth]#ll
  3. 总用量20
  4. -rw-r--r--167974users62910月701:52BUILDING.txt
  5. -rw-r--r--167974users702810月701:52pom.xml
  6. -rw-r--r--167974users54510月701:52README.txt
  7. drwxr-xr-x567974users409610月701:52src
  8. [root@masterhadoop-auth]#vimpom.xml
  1. <dependency>
  2. <groupId>org.mortbay.jetty</groupId>
  3. <artifactId>jetty-util</artifactId>
  4. <scope>test</scope>
  5. </dependency>
  1. [root@masterhadoop-auth]#cd../../
  2. [root@masterhadoop-2.2.0-src]#ll
  3. 总用量108
  4. -rw-r--r--167974users996810月701:53BUILDING.txt
  5. drwxr-xr-x267974users409610月702:45dev-support
  6. drwxr-xr-x367974users409610月702:45hadoop-assemblies
  7. drwxr-xr-x267974users409610月702:45hadoop-client
  8. drwxr-xr-x867974users409610月702:45hadoop-common-project
  9. drwxr-xr-x267974users409610月702:45hadoop-dist
  10. drwxr-xr-x667974users409610月702:45hadoop-hdfs-project
  11. drwxr-xr-x1067974users409610月702:45hadoop-mapreduce-project
  12. drwxr-xr-x367974users409610月702:45hadoop-maven-plugins
  13. drwxr-xr-x267974users409610月702:45hadoop-minicluster
  14. drwxr-xr-x367974users409610月702:45hadoop-project
  15. drwxr-xr-x267974users409610月702:45hadoop-project-dist
  16. drwxr-xr-x1167974users409610月702:45hadoop-tools
  17. drwxr-xr-x367974users409610月702:45hadoop-yarn-project
  18. -rw-r--r--167974users1516410月702:46LICENSE.txt
  19. -rw-r--r--167974users10110月702:46NOTICE.txt
  20. -rw-r--r--167974users1656910月701:53pom.xml
  21. -rw-r--r--167974users136610月702:46README.txt
  1. [root@masterhadoop-2.2.0-src]#mvnpackage-DskipTests-Pdist,native
  1. [INFO]------------------------------------------------------------------------
  2. [INFO]ReactorSummary:
  3. [INFO]
  4. [INFO]ApacheHadoopMain................................SUCCESS[02:36min]
  5. [INFO]ApacheHadoopProjectPOM.........................SUCCESS[01:17min]
  6. [INFO]ApacheHadoopAnnotations.........................SUCCESS[34.374s]
  7. [INFO]ApacheHadoopAssemblies..........................SUCCESS[0.217s]
  8. [INFO]ApacheHadoopProjectDistPOM....................SUCCESS[41.527s]
  9. [INFO]ApacheHadoopMavenPlugins.......................SUCCESS[43.952s]
  10. [INFO]ApacheHadoopAuth................................SUCCESS[33.819s]
  11. [INFO]ApacheHadoopAuthExamples.......................SUCCESS[11.162s]
  12. [INFO]ApacheHadoopCommon..............................SUCCESS[04:40min]
  13. [INFO]ApacheHadoopNFS.................................SUCCESS[16.089s]
  14. [INFO]ApacheHadoopCommonProject......................SUCCESS[0.035s]
  15. [INFO]ApacheHadoopHDFS................................SUCCESS[02:29min]
  16. [INFO]ApacheHadoopHttpFS..............................SUCCESS[16.069s]
  17. [INFO]ApacheHadoopHDFSBookKeeperJournal.............SUCCESS[01:15min]
  18. [INFO]ApacheHadoopHDFS-NFS............................SUCCESS[3.178s]
  19. [INFO]ApacheHadoopHDFSProject........................SUCCESS[0.025s]
  20. [INFO]hadoop-yarn.......................................SUCCESS[01:17min]
  21. [INFO]hadoop-yarn-api...................................SUCCESS[41.931s]
  22. [INFO]hadoop-yarn-common................................SUCCESS[23.424s]
  23. [INFO]hadoop-yarn-server................................SUCCESS[0.077s]
  24. [INFO]hadoop-yarn-server-common.........................SUCCESS[7.492s]
  25. [INFO]hadoop-yarn-server-nodemanager....................SUCCESS[13.799s]
  26. [INFO]hadoop-yarn-server-web-proxy......................SUCCESS[3.021s]
  27. [INFO]hadoop-yarn-server-resourcemanager................SUCCESS[10.077s]
  28. [INFO]hadoop-yarn-server-tests..........................SUCCESS[0.305s]
  29. [INFO]hadoop-yarn-client................................SUCCESS[4.342s]
  30. [INFO]hadoop-yarn-applications..........................SUCCESS[0.102s]
  31. [INFO]hadoop-yarn-applications-distributedshell.........SUCCESS[3.759s]
  32. [INFO]hadoop-mapreduce-client...........................SUCCESS[0.044s]
  33. [INFO]hadoop-mapreduce-client-core......................SUCCESS[19.331s]
  34. [INFO]hadoop-yarn-applications-unmanaged-am-launcher....SUCCESS[1.776s]
  35. [INFO]hadoop-yarn-site..................................SUCCESS[0.088s]
  36. [INFO]hadoop-yarn-project...............................SUCCESS[10.864s]
  37. [INFO]hadoop-mapreduce-client-common....................SUCCESS[16.493s]
  38. [INFO]hadoop-mapreduce-client-shuffle...................SUCCESS[2.516s]
  39. [INFO]hadoop-mapreduce-client-app.......................SUCCESS[8.973s]
  40. [INFO]hadoop-mapreduce-client-hs........................SUCCESS[4.314s]
  41. [INFO]hadoop-mapreduce-client-jobclient.................SUCCESS[5.121s]
  42. [INFO]hadoop-mapreduce-client-hs-plugins................SUCCESS[1.646s]
  43. [INFO]ApacheHadoopMapReduceExamples..................SUCCESS[5.443s]
  44. [INFO]hadoop-mapreduce..................................SUCCESS[2.021s]
  45. [INFO]ApacheHadoopMapReduceStreaming.................SUCCESS[4.114s]
  46. [INFO]ApacheHadoopDistributedCopy....................SUCCESS[26.639s]
  47. [INFO]ApacheHadoopArchives............................SUCCESS[1.992s]
  48. [INFO]ApacheHadoopRumen...............................SUCCESS[5.204s]
  49. [INFO]ApacheHadoopGridmix.............................SUCCESS[3.827s]
  50. [INFO]ApacheHadoopDataJoin...........................SUCCESS[2.590s]
  51. [INFO]ApacheHadoopExtras..............................SUCCESS[2.658s]
  52. [INFO]ApacheHadoopPipes...............................SUCCESS[6.587s]
  53. [INFO]ApacheHadoopToolsDist..........................SUCCESS[1.103s]
  54. [INFO]ApacheHadoopTools...............................SUCCESS[0.023s]
  55. [INFO]ApacheHadoopDistribution........................SUCCESS[7.099s]
  56. [INFO]ApacheHadoopClient..............................SUCCESS[2.781s]
  57. [INFO]ApacheHadoopMini-Cluster........................SUCCESS[0.072s]
  58. [INFO]------------------------------------------------------------------------
  59. [INFO]BUILDSUCCESS
  60. [INFO]------------------------------------------------------------------------
  61. [INFO]Totaltime:21:12min
  62. [INFO]Finishedat:2014-03-18T06:35:50+00:00
  63. [INFO]FinalMemory:141M/461M
  64. [INFO]------------------------------------------------------------------------
编译安装完成结果信息。
  1. [root@testhadoop-2.2.0-src]#cdhadoop-dist/target/hadoop-2.2.0/
  2. [root@testhadoop-2.2.0]#ll
  3. 总用量28
  4. drwxr-xr-x.2rootroot40963月1806:35bin
  5. drwxr-xr-x.3rootroot40963月1806:35etc
  6. drwxr-xr-x.2rootroot40963月1806:35include
  7. drwxr-xr-x.3rootroot40963月1806:35lib
  8. drwxr-xr-x.2rootroot40963月1806:35libexec
  9. drwxr-xr-x.2rootroot40963月1806:35sbin
  10. drwxr-xr-x.4rootroot40963月1806:35share
  11. [root@masterhadoop-2.2.0]#pwd
  12. /root/hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0
查看版本。
  1. [root@masterhadoop-2.2.0]#exportJAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64/
  2. [root@masterhadoop-2.2.0]#bin/hadoopversion
  3. Hadoop2.2.0
  4. SubversionUnknown-rUnknown
  5. Compiledbyrooton2014-03-18T06:24Z
  6. Compiledwithprotoc2.5.0
  7. Fromsourcewithchecksum79e53ce7994d1628b240f09af91e1af4
  8. Thiscommandwasrunusing/root/hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0/share/hadoop/common/hadoop-common-2.2.0.jar
编译完成,谢谢!

参考

http://hadoop.apache.org/

http://zh.wikipedia.org/zh-cn/Apache_Hadoop

http://book.51cto.com/art/201004/196447.htm

http://www.superwu.cn/2013/12/26/913/

http://zh.wikipedia.org/wiki/Apache_Maven