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

[经验分享] hadoop 源码编译 导入eclipse

[复制链接]
发表于 2016-12-4 10:11:01 | 显示全部楼层 |阅读模式
hadoop 源码编译 导入eclipse

      hadoop2版本出来后,突然心血来潮想编译下hadoop2的代码并导入eclipse,以备以后有时间了进行代码研究用,现在总结了下编译过程以及如何导入到elipse。一下是必备条件




  • hadoop版本:hadoop的尝鲜版release-2.0.3-alpha,svn地址:http://svn.apache.org/repos/asf/hadoop/common/tags
  • JDK1.6

  • ANT 及ivy,下载ant,配置环境变量,将ivy的下载jar包放到ant的lib目录下,即:%ANT_HOME%/lib

  • mvn3.0
  • 装protoc buffer http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz,将下载的的包解压,然后将protoc.exe复制到 cygwin的bin目录(%cygwin_home%/bin),

  • 安装cygwin,在win下面,首先下载cygwin:http://www.cygwin.com/ 在path中设置路径
    以下是需要注意修改的地方:
1、由于编译的源码过大,以至于mvn编译过程中会出现内存溢出,所以需要设置mvn的编译内存,打开mvn  的bin目录下的mvn.bat文件,添加set MAVEN_OPTS= -Xms128m -Xmx1024m。

2、由于在执行过程中mvn的mojo不能执行sh脚本文件,如在<executable>saveVersion.sh</executable>

,所以需要做如下修改,在elease-2.0.3-alpha\hadoop-yarn-project\hadoop-yarn\hadoop-yarn-common目录下和pom.xml同一目录,新建saveVersion.bat的文件,文件内容是调用saveVersion.sh文件,如:sh scripts\saveVersion.sh %1 %2

3、修改release-2.0.3-alpha\hadoop-yarn-project\hadoop-yarn\hadoop-yarn-common\scripts\saveVersion.sh文件,修改user=`who 为user=hdfs,因为在windows环境下活不到用户名,会出现编译page-info的类出错

最后按着hadoop的wiki(http://wiki.apache.org/hadoop/EclipseEnvironment)进行编译打包:


$ mvn install -DskipTests
$ mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
Note: This may take a while the first time, as all libraries are fetched from the internet, and the whole build is performed.
 

In Eclipse

After the above, do the following to finally have projects in Eclipse ready and waiting for you to go on that scratch-itching development spree:
For Common



  • File -> Import...

  • Choose "Existing Projects into Workspace"
  • Select the hadoop-common-project directory as the root directory
  • Select the hadoop-annotations, hadoop-auth, hadoop-auth-examples and hadoop-common projects
  • Click "Finish"

  • File -> Import...

  • Choose "Existing Projects into Workspace"
  • Select the hadoop-assemblies directory as the root directory
  • Select the hadoop-assemblies project
  • Click "Finish"
  • To get the projects to build cleanly:
  • * Add target/generated-test-sources/java as a source directory for hadoop-common

  • * You may have to add then remove the JRE System Library to avoid errors due to access restrictions


For HDFS



  • File -> Import...

  • Choose "Existing Projects into Workspace"
  • Select the hadoop-hdfs-project directory as the root directory
  • Select the hadoop-hdfs project
  • Click "Finish"

For MapReduce



  • File -> Import...

  • Choose "Existing Projects into Workspace"
  • Select the hadoop-mapreduce-project directory as the root directory
  • Select the hadoop-mapreduce-project project
  • Click "Finish"

 

运维网声明 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.iyunv.com/thread-309430-1-1.html 上篇帖子: hadoop的安全问题处理 下篇帖子: Hadoop 退出安全模式
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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