一、配置文件

1.core-site.xml

<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://www.node1.com:9000</value>
</property>
</configuration>

2、hdfs-site.xml

<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>

3、yarn-site.xml

<property>
<name>yarn.resourcemanager.hostname</name>
<value>www.node1.com</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>

4、slaves

www.node2.com
www.node3.com

二、建立本地连接

三、创建MapReduceProject

1、File  -- new - Other  --MapReduceProject

2、建立测试文件

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(otherArgs.length);
System.err.println("Usage: wordcount <in> <out>");
System.exit(2);
}
System.out.println(otherArgs[0]);
System.out.println(otherArgs[1]);
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);
}
}

3、run configuration

hdfs://www.node1.com:9000/usr/wc
hdfs://www.node1.com:9000/usr/wc/output

4、run

5、part-r-00000

apple    2
banana 1
cat 1
dog 1
hadoop 1
hadpp 1
hello 1
mapreduce 1
name 1
world 1
yarn 2

6、wc.txt

hadoop hello
hadpp world
apple dog
banana cat
mapreduce name
yarn
apple
yarn

【大数据系列】windows下连接Linux环境开发的更多相关文章

  1. 在Windows下配置Linux远程开发环境

    在Windows下配置Linux远程开发环境 欢迎光临我的个人博客 https://source.chens.life/Configure-Linux-remote-development-envir ...

  2. 在windows下使用linux的开发环境

    windows下做开发确实有些不方便,比如python.ruby什么的都要自己装,不过这还是小事情.有一次想安装node-sass,windows下报错缺少MSBuild什么的,可能需要装一个vs解决 ...

  3. 【大数据系列】win10上安装hadoop开发环境

    为了方便采用了Cygwin模拟linux环境的方法 一.安装JDK以及下载hadoop hadoop官网下载hadoop http://hadoop.apache.org/releases.html  ...

  4. 【大数据系列】在windows下连接linux 下的hadoop环境进行开发

    一.下载Eclipse并安装 二.下载exlipse的hadoop plugin 三.打开Map Reduce视图 Window --> Perspective --> Open pers ...

  5. 大数据:Windows下配置flink的Stream

    对于开发人员来说,最希望的是需要在windows中进行测试,然后把调试好的程序放在集群中运行.下面写一个Socket,上面是监控本地的一个运行端口,来实时的提取数据.获取视频中文档资料及完整视频的伙伴 ...

  6. Android学习——windows下搭建Cygwin环境

    在上一篇博文<Android学习——windows下搭建NDK_r9环境>中,我们详细的讲解了在windows下进行Android NDK开发环境的配置,我们也讲到了在NDk r7以后,我 ...

  7. windows下搭建Cygwin环境

    windows下搭建Cygwin环境 在上一篇博文<Android学习——windows下搭建NDK_r9环境>中,我们详细的讲解了在windows下进行Android NDK开发环境的配 ...

  8. 12.Linux软件安装 (一步一步学习大数据系列之 Linux)

    1.如何上传安装包到服务器 有三种方式: 1.1使用图形化工具,如: filezilla 如何使用FileZilla上传和下载文件 1.2使用 sftp 工具: 在 windows下使用CRT 软件 ...

  9. 【转】linux和windows下安装python集成开发环境及其python包

    本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...

随机推荐

  1. (转)并行编译 Xoreax IncrediBuild

    出自:http://blog.csdn.net/yockie/article/details/16867457 以前完全没有接触过分布式编译,今天因工作需要尝试了一下,绝对很强大,体验也非常好,绝对让 ...

  2. Toggle Checkboxes on/off

    You can write: $(document).ready(function() { $("#select-all-teammembers").click(function( ...

  3. Unity3d游戏开发中使用可空类型(Nullable Types)

    你怎么确定一个Vector3,int,或float变量是否被分配了一个值?一个方便的方式就是使用可空类型! 有时变量携带重要信息,但仅仅有在特定的游戏事件发生时触发.比如:一个角色在你的游戏可能闲置, ...

  4. Java编程思想学习笔记——类的访问权限

    类的访问权限 Java中,访问权限修饰词用于确定库中哪些类对于该库的使用者是可用的. public class Foo{ } 注意点: 每个文件(编译单元)只能有一个public类. public类的 ...

  5. vue的手机端框架mint-ui头部header组件实现返回到上一个浏览页面

    <mt-header title="中文号主页" fixed> <router-link to="" slot="left" ...

  6. Python中dataframe数据框中选择某一列非空的行

    利用pandas自带的函数notnull可以很容易判断某一列是否为null类型,但是如果这一列中某一格为空字符串"",此时notnull函数会返回True,而一般我们选择非空行并不 ...

  7. 禁用滚动视图ListView、ViewPager、ScrollView、HorizontalScrollView、WebView边界颜色渐变

    禁用滚动视图ListView.ViewPager.ScrollView.HorizontalScrollView.WebView边界颜色渐变 ListView.ViewPager.ScrollView ...

  8. JQuery难点备忘

    1 jquery绑定事件如何传递参数 $("#btn").bind("click",{"id":"111"," ...

  9. OpenGl 知识一

    写在前面 啦啦啦,搞了很久的Unity Shaders,越学越觉得基础知识很重要.学Unity Shader的时候,总会想,shader到底是什么呢?shader的pipeline是什么呢?它们是怎么 ...

  10. GSAP JS基础教程--TweenLite操作元素的相关属性

    今天来学习用TweenLite操作元素的各种属性,以Div为例,其他元素的操作也是一样的,只是可能一些元素有它们的特殊属性,就可能不同罢了.   代码里用详细注释,我就不再重复啦,大家看代码就可以啦! ...