阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Linux下编译Hadoop的Eclipse插件

435次阅读
没有评论

共计 9846 个字符,预计需要花费 25 分钟才能阅读完成。

虽然使用 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”>

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-11/92528p2.htm

相关阅读

Ubuntu 13.04 上搭建 Hadoop 环境 http://www.linuxidc.com/Linux/2013-06/86106.htm

Ubuntu 上搭建 Hadoop 环境(单机模式 + 伪分布模式)http://www.linuxidc.com/Linux/2013-01/77681.htm

Ubuntu 下 Hadoop 环境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm

单机版搭建 Hadoop 环境图文教程详解 http://www.linuxidc.com/Linux/2012-02/53927.htm

搭建 Hadoop 环境(在 Winodws 环境下用虚拟机虚拟两个 Ubuntu 系统进行搭建)http://www.linuxidc.com/Linux/2011-12/48894.htm

下文贴出整个 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

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

Linux 下编译 Hadoop 的 Eclipse 插件
 
最后,插件类生成的目录,截图如下:

Linux 下编译 Hadoop 的 Eclipse 插件
 
下面散仙给出所有配置的全部信息,以供参考,下图的是 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>

虽然使用 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”>

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-11/92528p2.htm

相关阅读

Ubuntu 13.04 上搭建 Hadoop 环境 http://www.linuxidc.com/Linux/2013-06/86106.htm

Ubuntu 上搭建 Hadoop 环境(单机模式 + 伪分布模式)http://www.linuxidc.com/Linux/2013-01/77681.htm

Ubuntu 下 Hadoop 环境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm

单机版搭建 Hadoop 环境图文教程详解 http://www.linuxidc.com/Linux/2012-02/53927.htm

搭建 Hadoop 环境(在 Winodws 环境下用虚拟机虚拟两个 Ubuntu 系统进行搭建)http://www.linuxidc.com/Linux/2011-12/48894.htm

build-contrib.xml 的核心配置如下:只有一个地方,notepad++,定位截图如下:

  <property name=”javac.deprecation” value=”on”/>

Linux 下编译 Hadoop 的 Eclipse 插件

下面是 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 编译完毕,截图如下

Linux 下编译 Hadoop 的 Eclipse 插件

启动 eclipse 后,截图如下:

Linux 下编译 Hadoop 的 Eclipse 插件

至此,插件已经完美生成,并运行

更多 Hadoop 相关信息见 Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计9846字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19350
评论数
4
阅读量
7962937
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
星哥带你玩飞牛NAS硬件 01:捡垃圾的最爱双盘,暴风二期矿渣为何成不老神话?

星哥带你玩飞牛NAS硬件 01:捡垃圾的最爱双盘,暴风二期矿渣为何成不老神话?

星哥带你玩飞牛 NAS 硬件 01:捡垃圾的最爱双盘,暴风二期矿渣为何成不老神话? 前言 在选择 NAS 用预...
【1024程序员】我劝你赶紧去免费领一个AWS、华为云等的主机

【1024程序员】我劝你赶紧去免费领一个AWS、华为云等的主机

【1024 程序员】我劝你赶紧去免费领一个 AWS、华为云等的主机 每年 10 月 24 日,程序员们都会迎来...
如何免费使用强大的Nano Banana Pro?附赠邪修的用法

如何免费使用强大的Nano Banana Pro?附赠邪修的用法

如何免费使用强大的 Nano Banana Pro?附赠邪修的用法 前言 大家好,我是星哥,今天来介绍谷歌的 ...
12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换,告别多工具切换

12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换,告别多工具切换

12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换...
星哥带你玩飞牛NAS硬件02:某鱼6张左右就可拿下5盘位的飞牛圣体NAS

星哥带你玩飞牛NAS硬件02:某鱼6张左右就可拿下5盘位的飞牛圣体NAS

星哥带你玩飞牛 NAS 硬件 02:某鱼 6 张左右就可拿下 5 盘位的飞牛圣体 NAS 前言 大家好,我是星...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
星哥带你玩飞牛NAS-16:不再错过公众号更新,飞牛NAS搭建RSS

星哥带你玩飞牛NAS-16:不再错过公众号更新,飞牛NAS搭建RSS

  星哥带你玩飞牛 NAS-16:不再错过公众号更新,飞牛 NAS 搭建 RSS 对于经常关注多个微...
12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换,告别多工具切换

12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换,告别多工具切换

12.2K Star 爆火!开源免费的 FileConverter:右键一键搞定音视频 / 图片 / 文档转换...
多服务器管理神器 Nexterm 横空出世!NAS/Win/Linux 通吃,SSH/VNC/RDP 一站式搞定

多服务器管理神器 Nexterm 横空出世!NAS/Win/Linux 通吃,SSH/VNC/RDP 一站式搞定

多服务器管理神器 Nexterm 横空出世!NAS/Win/Linux 通吃,SSH/VNC/RDP 一站式搞...
零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face 免费服务器 +Docker 快速部署 HertzBeat 监控平台 ...
150元打造低成本NAS小钢炮,捡一块3865U工控板

150元打造低成本NAS小钢炮,捡一块3865U工控板

150 元打造低成本 NAS 小钢炮,捡一块 3865U 工控板 一块二手的熊猫 B3 工控板 3865U,搭...