Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境

看不見的法師
发布: 2025-08-31 08:43:22
原创
779人浏览过

图文详解如何在windows 8.0上的eclipse 4.4.0中配置centos 6.5上的hadoop 2.2.0开发环境,供有需要的朋友参考学习。

Eclipse的Hadoop插件下载地址:https://www.php.cn/link/bf74cbe3722200f6fad86af0b239d900

下载压缩包后,解压并将hadoop-eclipse-kepler-plugin-2.2.0.jar文件放置到Eclipse的dropins目录中,重启Eclipse即可。

进入Windows -> Preferences配置根目录。

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境,这里的hadoop installation directory不是指你在Windows上安装的Hadoop目录,而是你在CentOS上编译好的源码在Windows上的解压路径。这个路径仅用于创建MapReduce项目时自动引入所需的jar文件。

进入Window -> Open Perspective -> Other -> Map/Reduce,打开Map/Reduce窗口。

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境找到

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境,右击选择New Hadoop location,这时会出现

码上飞
码上飞

码上飞(CodeFlying) 是一款AI自动化开发平台,通过自然语言描述即可自动生成完整应用程序。

码上飞 138
查看详情 码上飞

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境Map/Reduce(V2)中的配置对应于mapred-site.xml中的端口配置,DFS Master中的配置对应于core-site.xml中的端口配置,配置完成后点击finish即可。这时可以查看

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境进行测试,创建一个新的MapReduce项目,

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境,要解决这个问题,你需要在Windows上配置HADOOP_HOME,并将%HADOOP_HOME%in添加到path中。然后从https://github.com/srccodes/hadoop-common-2.2.0-bin下载文件,下载后将bin目录中的内容全部复制到你自己在Windows上的Hadoop bin目录中,覆盖即可。同时,将hadoop.dll添加到C盘的system32目录中。如果完成这些步骤后仍然遇到“Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z”,请检查你的JDK版本,可能是由于使用了32位JDK导致的,需要下载并安装64位JDK,并在Eclipse中将JRE环境配置为新安装的64位JRE。

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境。比如我的jre1.8是64位,而jre7是32位,如果列表中没有你需要的JRE,直接点击add添加即可,选择你的64位JRE环境后,问题就会解决。

接下来编写一个wordcount程序进行测试,下面是我的代码,前提是你已经在HDFS上创建了input文件,并在其中放置了一些内容:

import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;

public class WordCount {
    public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> {
        private final static IntWritable one = new IntWritable(1);
        private Text word = new Text();

        public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
            StringTokenizer itr = new StringTokenizer(value.toString());
            while (itr.hasMoreTokens()) {
                word.set(itr.nextToken());
                context.write(word, one);
            }
        }
    }

    public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
        private IntWritable result = new IntWritable();

        public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
            int sum = 0;
            for (IntWritable val : values) {
                sum += val.get();
            }
            result.set(sum);
            context.write(key, result);
        }
    }

    public static void main(String[] args) throws Exception {
        // System.setProperty("hadoop.home.dir", "E:\\hadoop2.2\\");
        Configuration conf = new Configuration();
        String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
        // if (otherArgs.length != 2) {
        //     System.err.println("Usage: wordcount <in><out>");
        //     System.exit(2);
        // }
        Job job = new Job(conf, "word count");
        job.setJarByClass(WordCount.class);
        job.setMapperClass(TokenizerMapper.class);
        job.setCombinerClass(IntSumReducer.class);
        job.setReducerClass(IntSumReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);
        FileInputFormat.addInputPath(job, new Path("hdfs://master:9000/input"));
        FileOutputFormat.setOutputPath(job, new Path("hdfs://master:9000/output"));
        boolean flag = job.waitForCompletion(true);
        System.out.print("SUCCEED!" + flag);
        System.exit(flag ? 0 : 1);
        System.out.println();
    }
}
登录后复制

Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境

以上就是Windows 8.0上Eclipse 4.4.0 配置CentOS 6.5 上的Hadoop2.2.0开发环境的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号