设为首页 收藏本站
查看: 647|回复: 0

[经验分享] 64位ubuntu下重新编译hadoop2.2流水账

[复制链接]

尚未签到

发表于 2017-2-28 09:26:45 | 显示全部楼层 |阅读模式
  hadoop官方网站中只提供了32位的hadoop-2.2.0.tar.gz,如果要在64位ubuntu下部署hadoop-2.2.0,就需要重新编译源码包,生成64位的部署包。
建议以下操作使用root账户,避免出现权限不足的问题。

安装jdk
  请参考文章《在ubuntu中安装jdk》。

安装maven
  请参考文章《在ubuntu中安装maven》。

下载hadoop源码



wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0-src.tar.gz
解压



tar -xzf hadoop-2.2.0-src.tar.gz
编译源代码



cd hadoop-2.2.0-src
mvn package -Pdist,native -DskipTests -Dtar
第1次编译:失败(hadoop pom.xml的bug)
  错误信息:



[ERROR] Failed to execute goal on project hadoop-auth: Could not resolve dependencies for project org.apache.hadoop:hadoop-auth:jar:2.2.0: Could not transfer artifact org.mortbay.jetty:jetty:jar:6.1.26 from/to central (https://repo.maven.apache.org/maven2): GET request of: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar from central failed: SSL peer shut down incorrectly -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :hadoop-auth
  解决办法:
这是hadoop的一个bug,在pom.xml中添加下面patch即可,详见https://issues.apache.org/jira/browse/HADOOP-10110 。
  编辑`hadoop-common-project/hadoop-auth/pom.xml`文件:



vi hadoop-common-project/hadoop-auth/pom.xml
  在<dependencys></dependencys>节点中插入:



<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
第2次编译:失败(未安装protoc)
  错误信息:



[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.2.0:protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version -&gt; [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :hadoop-common
  解决办法:
  根据错误信息可以知道是因为没有安装protoc。



wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
tar -xzf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure
make
make check
make install
  其中,在执行./configure命令是会报如下错误:



checking whether to enable maintainer-specific portions of Makefiles... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/hadoop/protobuf-2.5.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
  提示我们找不到C编译器,因此我们还需要安装C编译器。
  ubuntu提供了集成gcc等编译器的基本编译工具`build-essential`,安装起来也比较方便,只需要一行命令:



apt-get install build-essential
  安装过程中可能会提示包找不到,建议先更新下软件源:



apt-get update
  安装之后验证protobuf的时候可能会报错以下错误:



$ protoc --version
protoc: error while loading shared libraries: libprotoc.so.8: cannot open shared object file: No such file or directory
  解决如下:



$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
$ protoc --version
libprotoc 2.5.0
第3次编译:失败(未安装cmake)
  错误信息:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "cmake" (in directory "/home/hadoop/hadoop-2.2.0-src/hadoop-common-project/hadoop-common/target/native"): error=2, No such file or directory -&gt; [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :hadoop-common
  解决办法:



apt-get install cmake
第4次编译:失败(未安装libglib2.0-dev)
  错误信息:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common: An Ant BuildException has occured: exec returned: 1 -&gt; [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :hadoop-common
  解决办法:



apt-get install libglib2.0-dev
第5次编译:失败(未安装libssl-dev)
  错误信息:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-pipes: An Ant BuildException has occured: exec returned: 1 -&gt; [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :hadoop-pipes
  解决办法:



apt-get install libssl-dev
第6次编译:成功



[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Hadoop Main ................................. SUCCESS [ 13.578 s]
[INFO] Apache Hadoop Project POM .......................... SUCCESS [ 5.183 s]
[INFO] Apache Hadoop Annotations .......................... SUCCESS [ 9.527 s]
[INFO] Apache Hadoop Assemblies ........................... SUCCESS [ 1.268 s]
[INFO] Apache Hadoop Project Dist POM ..................... SUCCESS [ 4.717 s]
[INFO] Apache Hadoop Maven Plugins ........................ SUCCESS [ 9.966 s]
[INFO] Apache Hadoop Auth ................................. SUCCESS [ 7.368 s]
[INFO] Apache Hadoop Auth Examples ........................ SUCCESS [ 3.971 s]
[INFO] Apache Hadoop Common ............................... SUCCESS [02:27 min]
[INFO] Apache Hadoop NFS .................................. SUCCESS [ 14.996 s]
[INFO] Apache Hadoop Common Project ....................... SUCCESS [ 0.078 s]
[INFO] Apache Hadoop HDFS ................................. SUCCESS [02:32 min]
[INFO] Apache Hadoop HttpFS ............................... SUCCESS [ 30.260 s]
[INFO] Apache Hadoop HDFS BookKeeper Journal .............. SUCCESS [ 19.083 s]
[INFO] Apache Hadoop HDFS-NFS ............................. SUCCESS [ 8.313 s]
[INFO] Apache Hadoop HDFS Project ......................... SUCCESS [ 0.071 s]
[INFO] hadoop-yarn ........................................ SUCCESS [ 0.542 s]
[INFO] hadoop-yarn-api .................................... SUCCESS [01:07 min]
[INFO] hadoop-yarn-common ................................. SUCCESS [ 48.948 s]
[INFO] hadoop-yarn-server ................................. SUCCESS [ 0.314 s]
[INFO] hadoop-yarn-server-common .......................... SUCCESS [ 18.413 s]
[INFO] hadoop-yarn-server-nodemanager ..................... SUCCESS [ 23.891 s]
[INFO] hadoop-yarn-server-web-proxy ....................... SUCCESS [ 5.687 s]
[INFO] hadoop-yarn-server-resourcemanager ................. SUCCESS [ 24.345 s]
[INFO] hadoop-yarn-server-tests ........................... SUCCESS [ 0.721 s]
[INFO] hadoop-yarn-client ................................. SUCCESS [ 8.261 s]
[INFO] hadoop-yarn-applications ........................... SUCCESS [ 0.168 s]
[INFO] hadoop-yarn-applications-distributedshell .......... SUCCESS [ 6.632 s]
[INFO] hadoop-mapreduce-client ............................ SUCCESS [ 0.261 s]
[INFO] hadoop-mapreduce-client-core ....................... SUCCESS [ 40.147 s]
[INFO] hadoop-yarn-applications-unmanaged-am-launcher ..... SUCCESS [ 3.497 s]
[INFO] hadoop-yarn-site ................................... SUCCESS [ 0.164 s]
[INFO] hadoop-yarn-project ................................ SUCCESS [ 6.054 s]
[INFO] hadoop-mapreduce-client-common ..................... SUCCESS [ 29.892 s]
[INFO] hadoop-mapreduce-client-shuffle .................... SUCCESS [ 5.450 s]
[INFO] hadoop-mapreduce-client-app ........................ SUCCESS [ 18.558 s]
[INFO] hadoop-mapreduce-client-hs ......................... SUCCESS [ 9.045 s]
[INFO] hadoop-mapreduce-client-jobclient .................. SUCCESS [ 7.740 s]
[INFO] hadoop-mapreduce-client-hs-plugins ................. SUCCESS [ 2.819 s]
[INFO] Apache Hadoop MapReduce Examples ................... SUCCESS [ 12.523 s]
[INFO] hadoop-mapreduce ................................... SUCCESS [ 5.321 s]
[INFO] Apache Hadoop MapReduce Streaming .................. SUCCESS [ 8.999 s]
[INFO] Apache Hadoop Distributed Copy ..................... SUCCESS [ 13.044 s]
[INFO] Apache Hadoop Archives ............................. SUCCESS [ 3.739 s]
[INFO] Apache Hadoop Rumen ................................ SUCCESS [ 11.307 s]
[INFO] Apache Hadoop Gridmix .............................. SUCCESS [ 8.223 s]
[INFO] Apache Hadoop Data Join ............................ SUCCESS [ 6.296 s]
[INFO] Apache Hadoop Extras ............................... SUCCESS [ 6.341 s]
[INFO] Apache Hadoop Pipes ................................ SUCCESS [ 14.662 s]
[INFO] Apache Hadoop Tools Dist ........................... SUCCESS [ 2.694 s]
[INFO] Apache Hadoop Tools ................................ SUCCESS [ 0.063 s]
[INFO] Apache Hadoop Distribution ......................... SUCCESS [ 44.996 s]
[INFO] Apache Hadoop Client ............................... SUCCESS [ 16.908 s]
[INFO] Apache Hadoop Mini-Cluster ......................... SUCCESS [ 5.014 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15:23 min
[INFO] Finished at: 2014-10-04T14:54:28+08:00
[INFO] Final Memory: 69M/215M
[INFO] ------------------------------------------------------------------------
编译成果
  编译生产的文件在`~/hadoop-2.2.0-src/hadoop-dist/target`目录中。



$ ls ~/hadoop-2.2.0-src/hadoop-dist/target
antrun hadoop-2.2.0 hadoop-dist-2.2.0-javadoc.jar test-dir
dist-layout-stitching.sh hadoop-2.2.0.tar.gz javadoc-bundle-options
dist-tar-stitching.sh hadoop-dist-2.2.0.jar maven-archiver
  其中hadoop-2.2.0是编译后的文件夹,hadoop-2.2.0.tar.gz是编译后的打包文件。

验证



$ cd ~/hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0/lib/native/
$ file libhadoop.so.1.0.0
libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=fb43b4ebd092ae8b4a427719b8907e6fdb223ed9, not stripped
  可以看到,libhadoop.so.1.0.0已经是64位的了。

拷贝
  将编译好的64位hadoop-2.2.0.tar.gz部署包,拷贝到当前用户目录。



cp ~/hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0.tar.gz ~

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-348226-1-1.html 上篇帖子: Maven学习总结(三)——使用Maven构建项目 下篇帖子: IntelliJ IDEA上创建maven Spring MVC项目
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表