win7下cygwin+hadoop+MyEclipse
1、启动cygwin服务
ssh localhost
//进入hadoop安装目录,注意文件分布系统在与windows有区别。
cd /cygdrive/d/hadoop/run/bin
2、启动hadoop
./start-all.sh
详细方法:http://lusterfly.iteye.com/blog/1813967
3、MyEclipse配置hadoop
【Window】->【Open Perspective】->【Other...】->【Map/Reduce】->【OK】
【Window】->【Show View】->【Other...】->【MapReduce Tools】->【Map/Reduce Locations】->【OK】
注意:Location name随便填,Map/Reduce Master中的host与port在conf文件夹下mapred-site.xml里面mapred.job.tracker里面的ip和port 。
DFS Master是core-site.xml里面fs.default.name里面的ip和port
4、wordCount程序
源码:
package org.apache.hadoop.examples;
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 {
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(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
(1) hadoop的安装目录下新建input文件夹(与bin文件夹在同一级目录),文件夹里新建两个文件。
(2)将文件夹上传到hdfs : bin/hadoop fs -put input in
(3) 配置运行参数:Run As-->Run Configurations ,Arguments中
读入程序的文件夹:hdfs://localhost:9000/user/shirely-pc/cyg_server/in/*
输出结果的文件夹:hdfs://localhost:9000/user/shirely-pc/cyg_server/out/*
虚拟机配置: -xmx1024m 解决java heap out
详细解决方法:http://my.oschina.net/u/570654/blog/112780
win7下cygwin+hadoop+MyEclipse相关推荐
- WIN7下运行hadoop程序报:Failed to locate the winutils binary in the hadoop binary path
项目中用到了Hbase,貌似用了Hadoop. 项目启动的时候,报了错,但是不影响正常使用. 但是,控制台有红色错误,看着不太爽,就想办法把这个问题解决了. 错误提示"Failed to l ...
- Win7环境下Cygwin中Git可视化配置(gitk配置)
我们知道cygwin可以在windows系统中模拟linux开发环境,自然我们也就能够在其中配置git,配置git的教程很多了,网上一搜一大把,这里给一篇吧(不一定保证对),童鞋们可以去看看这篇Win ...
- win7下使用Taste实现协同过滤算法
如果要实现Taste算法,必备的条件是: 1) JDK,使用1.6版本.需要说明一下,因为要基于Eclipse构建,所以在设置path的值之前要先定义JAVA_HOME变量. 2) Maven,使用2 ...
- Win7下eclipse提交Job到hadoop集群
Win7下eclipse提交Job到hadoop集群 参考:http://zy19982004.iteye.com/blog/2031172 之前跑通eclipse连接hadoop2.2.0原来是lo ...
- Win7下如何删除“顽固文件”cygwin
前段时间在Win7下,在Cygwin的卸载中却出现问题:无权限删除文件夹,提示"需要管理员权限"."需要Administrator权限"即使你已经以Admini ...
- Win7下快速搭建hadoopEclipse运行环境--方案
apache提供了 Linux下开发hadoop教程,不多说 网上有很多参考资料,说法不一 自己总结下思路,希望能对喜欢hadoop的兄弟姐妹有所帮助: 硬件:win7 step 1. 安装1.6以上 ...
- cocos2d-x在win7下的android交叉编译环境
cocos2d-x在win7下的android交叉编译环境 前面把Visual Studio+Python开发环境配好了,但还没有讲如何在Android中使用创建好的项目,本篇博客介绍如何在win7下 ...
- 在win7下将CapsLock按键变成esc
在win7下将CapsLock按键变成esc 我喜欢用vim来编辑,经常要按到esc,但是去按那个按键确实比较的远,而且CapsLock这个按键对我来说着实有些鸡肋,所以就想在win7上也能像ubun ...
- Windows平台下安装Hadoop
http://www.cnblogs.com/kinglau/archive/2013/08/20/3270160.html 1.安装JDK1.6或更高版本 官网下载JDK,安装时注意,最好不要安装到 ...
最新文章
- Javascript导航菜单13则
- Java 快速排序算法实现-----面试
- Django在Win7下安装与创建项目hello word示例
- ORACLE的索引和约束详解
- Android创建文件为unix格式,Recovery模式下/cache/recovery/目录下创建文件,开机后文件被删除...
- Excel多因素可重复方差分析
- 微软正式释出基于 Chromium 的 Edge 预览版本
- 全体注意:@live.com 形势不妙,可能三周内被收回
- SPSS(1)--安装hayes process插件及用Bootstrap方法进行中介效应检验
- stc单片机c语言编程软件,stc isp官方下载-STC单片机ISP下载编程软件下载v6.85i 官方最新版-西西软件下载...
- dtech串口驱动 linux,帝特USB转串口驱动
- 分布式高并发下,Actor模型如此优秀
- XDUOJ题解合集(待填坑)
- Lab3 Attack Lab
- insmod 加载模块的过程
- Linux部署war包项目
- 软件构造 Lab3 CircularOrbit 实验日记
- STM32通过(软/硬IIC)控制LCD1602液晶显示屏(IIC转8位并口的PCF8574转接板的使用)原创
- 如何添加、修改和删除矢量线段
- Java选择题(八)