运行wordcount实例

在/tmp目录下生成两个文本文件,上面随便写两个单词。

cd /tmp/
mkdir file
cd file/
echo "Hello world" > file1.txt
cp file1.txt file2.txt

在hadoop平台中新建 /input 目录,这里不是系统的 / 目录。

cd /usr/local/hadoop-2.6.5
./bin/hadoop fs -mkdir /input
hadoop fs -ls / drwxr-xr-x - root supergroup 0 2018-01-04 09:32 /input

执行 ./bin/hadoop fs -mkdir /input 可能会遇到一个错误:

报错:
mkdir: Cannot create directory /input. Name node is in safe mode.
# 解决办法
bin/hadoop dfsadmin -safemode leave
_________________________________________ leave - 强制NameNode离开安全模式
enter - 进入安全模式
get - 返回安全模式是否开启的信息
wait - 等待,一直到安全模式结束。

把创建的文件放到hadoop平台的 /input中。

./bin/hadoop fs -put /tmp/file* /input
hadoop fs -ls /input/file Found 2 items
-rw-r--r-- 1 root supergroup 12 2018-01-04 09:32 /input/file/file1.txt
-rw-r--r-- 1 root supergroup 12 2018-01-04 09:32 /input/file/file2.txt

然后运行hadoop自带的example。

./bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.5.jar wordcount /input/file/ /output/wordcount1
_________________________________________ 18/01/04 09:54:09 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
18/01/04 09:54:10 INFO input.FileInputFormat: Total input paths to process : 2
18/01/04 09:54:10 INFO mapreduce.JobSubmitter: number of splits:2
18/01/04 09:54:10 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1515028606802_0002
18/01/04 09:54:10 INFO impl.YarnClientImpl: Submitted application application_1515028606802_0002
18/01/04 09:54:10 INFO mapreduce.Job: The url to track the job: http://iz2ze31g42iypc75mm363gz:8088/proxy/application_1515028606802_0002/
18/01/04 09:54:10 INFO mapreduce.Job: Running job: job_1515028606802_0002
18/01/04 09:54:18 INFO mapreduce.Job: Job job_1515028606802_0002 running in uber mode : false
18/01/04 09:54:18 INFO mapreduce.Job: map 0% reduce 0%
18/01/04 09:54:27 INFO mapreduce.Job: map 100% reduce 0%
18/01/04 09:54:33 INFO mapreduce.Job: map 100% reduce 100%
18/01/04 09:54:33 INFO mapreduce.Job: Job job_1515028606802_0002 completed successfully
18/01/04 09:54:33 INFO mapreduce.Job: Counters: 49
File System Counters
FILE: Number of bytes read=54
FILE: Number of bytes written=322109
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=238
HDFS: Number of bytes written=16
HDFS: Number of read operations=9
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Launched map tasks=2
Launched reduce tasks=1
Data-local map tasks=2
Total time spent by all maps in occupied slots (ms)=12913
Total time spent by all reduces in occupied slots (ms)=3521
Total time spent by all map tasks (ms)=12913
Total time spent by all reduce tasks (ms)=3521
Total vcore-milliseconds taken by all map tasks=12913
Total vcore-milliseconds taken by all reduce tasks=3521
Total megabyte-milliseconds taken by all map tasks=13222912
Total megabyte-milliseconds taken by all reduce tasks=3605504
Map-Reduce Framework
Map input records=2
Map output records=4
Map output bytes=40
Map output materialized bytes=60
Input split bytes=214
Combine input records=4
Combine output records=4
Reduce input groups=2
Reduce shuffle bytes=60
Reduce input records=4
Reduce output records=2
Spilled Records=8
Shuffled Maps =2
Failed Shuffles=0
Merged Map outputs=2
GC time elapsed (ms)=363
CPU time spent (ms)=1360
Physical memory (bytes) snapshot=499748864
Virtual memory (bytes) snapshot=6301630464
Total committed heap usage (bytes)=301146112
Shuffle Errors
BAD_ID=0
CONNECTION=0
IO_ERROR=0
WRONG_LENGTH=0
WRONG_MAP=0
WRONG_REDUCE=0
File Input Format Counters
Bytes Read=24
File Output Format Counters
Bytes Written=16

查看结果

./bin/hdfs dfs -cat /output/wordcount1/*
Hello 2
world 2

hadoop2.6.5运行wordcount实例的更多相关文章

  1. Hadoop3 在eclipse中访问hadoop并运行WordCount实例

    前言:       毕业两年了,之前的工作一直没有接触过大数据的东西,对hadoop等比较陌生,所以最近开始学习了.对于我这样第一次学的人,过程还是充满了很多疑惑和不解的,不过我采取的策略是还是先让环 ...

  2. hadoop运行wordcount实例,hdfs简单操作

    1.查看hadoop版本 [hadoop@ltt1 sbin]$ hadoop version Hadoop -cdh5.12.0 Subversion http://github.com/cloud ...

  3. Spark源码编译并在YARN上运行WordCount实例

    在学习一门新语言时,想必我们都是"Hello World"程序开始,类似地,分布式计算框架的一个典型实例就是WordCount程序,接触过Hadoop的人肯定都知道用MapRedu ...

  4. hadoop2.6.4运行wordcount

    hadoop用户登录,启动服务: start-dfs.sh && start-yarn.sh 创建输入目录: hadoop df -mkdir /input 把测试文件导入/input ...

  5. hadoop2.7.x运行wordcount程序卡住在INFO mapreduce.Job: Running job:job _1469603958907_0002

    一.抛出问题 Hadoop集群(全分布式)配置好后,运行wordcount程序测试,发现每次运行都会卡住在Running job处,然后程序就呈现出卡死的状态. wordcount运行命令:[hado ...

  6. Hadoop2.8.2 运行wordcount

    1 例子jar位置 [hadoop@hadoop02 mapreduce]$ pwd /hadoop/hadoop-2.8.2/share/hadoop/mapreduce [hadoop@hadoo ...

  7. CentOS上安装Hadoop2.7,添加数据节点,运行wordcount

    安装hadoop的步骤比较繁琐,但是并不难. 在CentOS上安装Hadoop2.7 1. 安装 CentOS,注:图形界面并无必要 2. 在CentOS里设置静态IP,手工编辑如下4个文件 /etc ...

  8. win10+eclipse+hadoop2.7.2+maven+local模式直接通过Run as Java Application运行wordcount

    一.准备工作 (1)Hadoop2.7.2 在linux部署完毕,成功启动dfs和yarn,通过jps查看,进程都存在 (2)安装maven 二.最终效果 在windows系统中,直接通过Run as ...

  9. Python实现MapReduce,wordcount实例,MapReduce实现两表的Join

    Python实现MapReduce 下面使用mapreduce模式实现了一个简单的统计日志中单词出现次数的程序: from functools import reduce from multiproc ...

随机推荐

  1. jlink烧写Nor Flash时出错正确解决方法汇总:PC of target system has unexpected value after programming

    成都国嵌的课程:国嵌体验入门班-2-1(开发板系统安装-Jlink方式).rar毒害了不少人,那种直接烧写nor flash,不进行任何配置的方法,能够成功纯属偶然,他自己在视频中烧写时也出现了两次错 ...

  2. Flex设置LinkButton的背景色

    1.设计思路    由于Flex中没有设置LinkButton的背景色的属性,现在得从两个方面入手:第一,直接通过调用样式方法画出LinkButton的背景色:第二,设置LinkButton的背景图片 ...

  3. freemarker.template.TemplateException:Macro has no such argument:params

    1.错误描述 freemarker.template.TemplateException:Macro mainSelect has no such argument:params 2.错误原因 在宏定 ...

  4. Struts2(四)Struts2配置文件的配置

    Struts2的常见配置 1.Struts2的配置文件的加载顺序: 每次从客户端发送到请求到服务器都要先从Struts2的核心过滤器StrutsPrepareAndExeccuteFilter,这个过 ...

  5. mac下安装ELK

    本文主要为自己所走弯路而做的补充,对小白(比如我)来讲某些博客讲的还是高深了,特地来此补充说明一些东西. 主要步骤参考http://blog.csdn.net/ywheel1989/article/d ...

  6. Eclipse远程debug服务器

    一,找端口号 二,Eclipse配置 三,测试是否成功 四,结束远程debug

  7. [Python爬虫]使用Selenium操作浏览器订购火车票

    这个专题主要说的是Python在爬虫方面的应用,包括爬取和处理部分 [Python爬虫]使用Python爬取动态网页-腾讯动漫(Selenium) [Python爬虫]使用Python爬取静态网页-斗 ...

  8. Project入门学习

    Microsoft Office Project制定项目计划时,针对每项任务是可以分配具体的资源的,比如由某个人完成某项任务,或者把某项设备分配到某项任务,这样便于项目的管理和人员.设备的安排及有效利 ...

  9. [UVAlive4297]First Knight

    题面在这里 题意 给定一个\(n\times m\)的格网,从\((1,1)\)出发,每一格\((i,j)\)往上下左右移动的概率已经给出,询问到达\((n,m)\)的期望步数 数据范围 \[n,m\ ...

  10. Centos samba 服务配置

    1背景 转到Linux有段时间了,vim操作还不能应对工程代码,之前一直都是Gnome桌面 + Clion 作开发环境,无奈在服务器上没有这样的环境, 看同事是(Windows)Source Insi ...