`
qindongliang1922
  • 浏览: 2152388 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
7265517b-f87e-3137-b62c-5c6e30e26109
证道Lucene4
浏览量:116483
097be4a0-491e-39c0-89ff-3456fadf8262
证道Hadoop
浏览量:124716
41c37529-f6d8-32e4-8563-3b42b2712a50
证道shell编程
浏览量:58722
43832365-bc15-3f5d-b3cd-c9161722a70c
ELK修真
浏览量:70512
社区版块
存档分类
最新评论

Linux下编译Hadoop的Eclipse插件

阅读更多
虽然使用Java编写MapReduce作业有点繁琐,但是对于刚入门hadoop的新手来说,有利于理解hadoop的一些底层实现,这无疑也是一种巨大的收获。目前大部分的MapReduce作业都是使用Hive,Pig完成的,当然也有用其他语言实现的,通过使用HadoopStreaming的方式,用原生Java写MR作业的只有很少一部分。在Hadoop2.x中,已经不支持eclipse的插件了,不过可以在配置的XML文件里,加入远程监控的端口,来监控hadoop集群。


由于1.0之后hadoop已经不自带eclipse的插件包了,所以得需要我们自己编译源码生成插件包,建议在Linux下编译,Windows下可能有时候会报一些莫名其妙的错误,先介绍下散仙的环境,Centos6.4的版本,hadoop1.2.0的版本,
hadoop的目录在/root/hadoop-1.2.0下面
eclipse的目录在/root/eclipse下面
总结一下如下的四步来完成编译eclipse插件的过程


步骤操作
1进入/root/hadoop-1.2.0/src/contrib/eclipse-plugin下面,修改build.xml
2进入/root/hadoop-1.2.0/src/contrib下面,修改build-contrib.xml
3/root/hadoop-1.2.0/src/contrib/eclipse-plugin/META-INF下面,修改MANIFEST.MF文件
4使用shell命令进入/root/hadoop-1.2.0/src/contrib/eclipse-plugin下面,执行ant命令进行构建


下面散仙就来详细介绍下,每一步具体怎么操作,在第一步里我们需要向build.xml里面,加入的内容有
1,eclipse的根目录.
2.hadoop的版本号.
3.hadoop的一些引用包.
4,在javac里加入  includeantruntime="on".
内容如下所示:


  <!-- 1,2步的配置  -->
  <property name="eclipse.home" location="/root/eclipse"/>
  <property name="version" value="1.2.0"/>
  <!--第3步的配置  -->
  <copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar"  tofile="${build.dir}/lib/commons-cli.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-configuration-1.6.jar"  tofile="${build.dir}/lib/commons-configuration.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-httpclient-3.0.1.jar"  tofile="${build.dir}/lib/commons-httpclient.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-lang-2.4.jar"  tofile="${build.dir}/lib/commons-lang.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar"  tofile="${build.dir}/lib/jackson-core-asl.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar"  tofile="${build.dir}/lib/jackson-mapper-asl.jar" verbose="true"/>
 <!--第4步的配置  -->
 includeantruntime="on">

散仙会在下文贴出整个XML,现在我们看第二大步的配置,修改build-contrib.xml,内容如下:
 <!--  原始的为off -->
<property name="javac.deprecation" value="on"/>

第三步的修改MANIFEST.MF内容如下:
Bundle-ClassPath: classes/,lib/commons-cli.jar,lib/commons-httpclient.jar,lib/hadoop-core.jar,lib/jackson-mapper-asl.jar,lib/commons-configuration.jar,lib/commons-lang.jar,lib/jackson-core-asl.jar



第四步执行命令:截图如下:


最后,插件类生成的目录,截图如下:




下面散仙给出所有配置的全部信息,以供参考,下图的是build.xml里面的内容


<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

             <!-- build.xml -->
<project default="jar" name="eclipse-plugin">

  <import file="../build-contrib.xml"/>

   
  <property name="eclipse.home" location="/root/eclipse"/>
  <property name="version" value="1.2.0"/>
  
  <path id="eclipse-sdk-jars">
    <fileset dir="${eclipse.home}/plugins/">
      <include name="org.eclipse.ui*.jar"/>
      <include name="org.eclipse.jdt*.jar"/>
      <include name="org.eclipse.core*.jar"/>
      <include name="org.eclipse.equinox*.jar"/>
      <include name="org.eclipse.debug*.jar"/>
      <include name="org.eclipse.osgi*.jar"/>
      <include name="org.eclipse.swt*.jar"/>
      <include name="org.eclipse.jface*.jar"/>

      <include name="org.eclipse.team.cvs.ssh2*.jar"/>
      <include name="com.jcraft.jsch*.jar"/>
    </fileset> 
  </path>

  <!-- Override classpath to include Eclipse SDK jars -->
  <path id="classpath">
    <pathelement location="${build.classes}"/>
    <pathelement location="${hadoop.root}/build/classes"/>
	 <fileset dir="${hadoop.root}">
        <include name="**/*.jar" />
    </fileset>
    <path refid="eclipse-sdk-jars"/>
  </path>

  <!-- Skip building if eclipse.home is unset. -->
  <target name="check-contrib" unless="eclipse.home">
    <property name="skip.contrib" value="yes"/>
    <echo message="eclipse.home unset: skipping eclipse plugin"/>
  </target>

 <target name="compile" depends="init, ivy-retrieve-common" unless="skip.contrib">
    <echo message="contrib: ${name}"/>
    <javac
     encoding="${build.encoding}"
     srcdir="${src.dir}"
     includes="**/*.java"
     destdir="${build.classes}"
     debug="${javac.debug}"
     deprecation="${javac.deprecation}"
	 includeantruntime="on">
     <classpath refid="classpath"/>
    </javac>
  </target>

  <!-- Override jar target to specify manifest -->
  <target name="jar" depends="compile" unless="skip.contrib">
    <mkdir dir="${build.dir}/lib"/>
  <!--  <copy file="${hadoop.root}/build/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/> -->
   <!--  <copy file="${hadoop.root}/build/ivy/lib/Hadoop/common/commons-cli-${commons-cli.version}.jar"  todir="${build.dir}/lib" verbose="true"/>-->
  <copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-cli-${commons-cli.version}.jar"  tofile="${build.dir}/lib/commons-cli.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-configuration-1.6.jar"  tofile="${build.dir}/lib/commons-configuration.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-httpclient-3.0.1.jar"  tofile="${build.dir}/lib/commons-httpclient.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/commons-lang-2.4.jar"  tofile="${build.dir}/lib/commons-lang.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar"  tofile="${build.dir}/lib/jackson-core-asl.jar" verbose="true"/>
<copy file="${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar"  tofile="${build.dir}/lib/jackson-mapper-asl.jar" verbose="true"/>


  <jar
      jarfile="${build.dir}/hadoop-${name}-${version}.jar"
      manifest="${root}/META-INF/MANIFEST.MF">
      <fileset dir="${build.dir}" includes="classes/ lib/"/>
      <fileset dir="${root}" includes="resources/ plugin.xml"/>
    </jar>
  </target>

</project>


build-contrib.xml的核心配置如下:只有一个地方,notepad++,定位截图如下:
  <property name="javac.deprecation" value="on"/>



下面是MANIFEST.MF里面的内容

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MapReduce Tools for Eclipse
Bundle-SymbolicName: org.apache.hadoop.eclipse;singleton:=true
Bundle-Version: 0.18
Bundle-Activator: org.apache.hadoop.eclipse.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.jdt.launching,
 org.eclipse.debug.core,
 org.eclipse.jdt,
 org.eclipse.jdt.core,
 org.eclipse.core.resources,
 org.eclipse.ui.ide,
 org.eclipse.jdt.ui,
 org.eclipse.debug.ui,
 org.eclipse.jdt.debug.ui,
 org.eclipse.core.expressions,
 org.eclipse.ui.cheatsheets,
 org.eclipse.ui.console,
 org.eclipse.ui.navigator,
 org.eclipse.core.filesystem,
 org.apache.commons.logging
Eclipse-LazyStart: true
Bundle-ClassPath: classes/,lib/commons-cli.jar,lib/commons-httpclient.jar,lib/hadoop-core.jar,lib/jackson-mapper-asl.jar,lib/commons-configuration.jar,lib/commons-lang.jar,lib/jackson-core-asl.jar
Bundle-Vendor: Apache Hadoop


至此,已经ant编译完毕,截图如下



启动eclipse后,截图如下:





至此,插件已经完美生成,并运行,因为受上传限制的影响,所以散仙在这里上传不了这个jar包,有需要的朋友们,可以联系散仙。

  • 大小: 76.3 KB
  • 大小: 49.6 KB
  • 大小: 90.2 KB
  • 大小: 31.8 KB
  • 大小: 58 KB
0
0
分享到:
评论
2 楼 gainyray 2014-01-02  
弄好了,将hadoop/hadoop-core-1.2.1.jar copy到hadoop/build下 然后执行命令: ant jar 就编译好了
1 楼 gainyray 2014-01-02  
楼主,最后编译得时候出现java.net.ConnectException: Connection timed out.
然后找到用ant compile -Doffline=true 这个命令编译,显示build sucessful.但是问题是在指定得路径下找不到编译好的jar包,楼主有时间看看,先谢谢了。。。

相关推荐

    Hadoop Eclipse插件2.2.0版本

    hadoop Eclipse插件Linux版本,编译环境hadoop2.2.0

    用于hadoop开发的eclipse插件

    本人编译的eclipse插件,验证使用正常。插件源码从github获取(hadoop2x-eclipse-plugin) 编译使用环境为: 操作系统:debian 7.6.0(32位) JDK版本:1.6.0_32 eclipse版本:4.4 hadoop版本:2.4.1

    hadoop2.7.1 eclipse 插件 64位linux版本

    在centos7进行编译出来的,亲测可用

    Eclipse-Hadoop2.7.5配套软件及插件

    2. 上述文件是配套的,本人亲测可以组合使用,注意,插件是基于jdk1.8编译的,如果要自行尝试其他jdk和eclipse,要留心版本匹配。 3. 如有小伙伴急需又没有积分下载,可以给我留言,看到了就私信分享给你。

    hadoop2.7.1eclipse插件

    hadoop2.7.1的linux下eclipse支持插件。已经经过检查,安装后在eclipse下,可以正常上传,下载,删除hdfs文件,以及跑mapreduce程序。 编译环境:ant1.9.6 jdk1.8 hadoop2.7.1

    hadoop2.6.5-eclipse插件编译完成

    Windows10 64位系统,eclipse下,连接Linux下hadoop的插件,已编译完成,可放置在eclipse安装目录plugins下,本版本已测试

    hadoop-eclipse-plugin-1.2.0

    自己编译的hadoop-1.2.0的eclipse插件,jdk1.6的。在windows和linux下测试可用。

    hadoop-eclipse-plugin-1.0.4.jar

    1.这个插件是我查阅资料后成功编译的,hadoop版本为1.0.4 eclipse为3.7,linux、win版本均可。 2.如果你之前尝试过别的hadoop-eclipse*jar插件而没有成功,此时eclipse已经"不干净了",需要新解压的eclipse,将该jar包...

    hadoop插件

    这是linux下的eclipse的hadoop插件,很方便,编译好的,不需要再去编译,直接放到plungins文件夹下,稍加配置即可跑起来。

    hadoop-eclipse-plugin-2.0.0-mr1-cdh4.4.0.jar 插件

    CDH最新版本CDH4.4版本,Mapreduce1插件,用于hadoop的开发!便于Mapreduce程序的编写和开发! 基于Linux下eclipse-jee-juno-SR2-linux-gtk-x86_64编译。

    hadoop-eclipse-plugin-2.7.2.jar

    hadoop-eclipse-plugin-2.7.2.jar 历尽千辛万苦,终于编译成功了本插件,并测试运行通过。 编译环境:hadoop2.7.2,eclipse-jee-mars-2-linux-gtk-x86_64.tar.gz

    hadoop云资源与安装

    - 文档hadoop2.4插件下载、完全分布式、伪分布、eclipse插件开发文档hadoop2完全分布式最新高可靠安装文档及整合hbase0.96安装从零教你在Linux环境下编译hadoop2.4及hadoop2.4汇总

    hadoop-eclipse-plugin-1.2.1.jar

    ant编译的hadoop-eclipse-plugin-1.2.1.jar 经测试eclipse-java-juno-SR2-linux-gtk.tar.gz 4.2.2 是成功的

    Hadoop技术内幕:深入解析MapReduce架构设计与实现原理

    阅读源代码前的准备1.1 准备源代码学习环境1.1.1 基础软件下载1.1.2 如何准备Windows环境1.1.3 如何准备Linux环境1.2 获取Hadoop源代码1.3 搭建Hadoop源代码阅读环境1.3.1 创建Hadoop工程1.3.2 Hadoop源代码...

    HadoopIntellijPlugin:HadoopIntelliJ IDEA插件

    与hadoop-eclipse-plugin相似的插件。 Intellij-Plugin-Hadoop接口大致如下: 特征 1,简单。 该插件易于使用,并支持Window和Linux。 2,可以支持对多个Hadoop文件系统的配置访问。 3,支持多国语言切换(目前仅...

Global site tag (gtag.js) - Google Analytics