HDFS基本命令与Hadoop MapReduce程序的执行
一、HDFS基本命令
1.创建目录:-mkdir
[jun@master ~]$ hadoop fs -mkdir /test
[jun@master ~]$ hadoop fs -mkdir /test/input
2.查看文件列表:-ls
[jun@master ~]$ hadoop fs -ls /
Found items
drwxr-xr-x - jun supergroup -- : /test
[jun@master ~]$ hadoop fs -ls /test
Found items
drwxr-xr-x - jun supergroup -- : /test/input
3.上传文件到HDFS
在/home/jun下新建两个文件jun.dat和jun.txt
(1)使用-put将文件从本地复制到HDFS集群
[jun@master ~]$ hadoop fs -put /home/jun/jun.dat /test/input/jun.dat
(2)使用-copyFromLocal将文件从本地复制到HDFS集群
[jun@master ~]$ hadoop fs -copyFromLocal -f /home/jun/jun.txt /test/input/jun.txt
(3)查看是否复制成功
[jun@master ~]$ hadoop fs -ls /test/input
Found items
-rw-r--r-- jun supergroup -- : /test/input/jun.dat
-rw-r--r-- jun supergroup -- : /test/input/jun.txt
4.下载文件到本地
(1)使用-get将文件从HDFS集群复制到本地
[jun@master ~]$ hadoop fs -get /test/input/jun.dat /home/jun/jun1.dat
(2)使用-copyToLocal将文件从HDFS集群复制到本地
[jun@master ~]$ hadoop fs -copyToLocal /test/input/jun.txt /home/jun/jun1.txt
(3)查看是否复制成功
[jun@master ~]$ ls -l /home/jun/
total
drwxr-xr-x. jun jun Jul : Desktop
drwxr-xr-x. jun jun Jul : Documents
drwxr-xr-x. jun jun Jul : Downloads
drwxr-xr-x. jun jun Jul : hadoop
drwxrwxr-x. jun jun Jul : hadoopdata
-rw-r--r--. jun jun Jul : jun1.dat
-rw-r--r--. jun jun Jul : jun1.txt
-rw-rw-r--. jun jun Jul : jun.dat
-rw-rw-r--. jun jun Jul : jun.txt
drwxr-xr-x. jun jun Jul : Music
drwxr-xr-x. jun jun Jul : Pictures
drwxr-xr-x. jun jun Jul : Public
drwxr-xr-x. jun jun Jul : Resources
drwxr-xr-x. jun jun Jul : Templates
drwxr-xr-x. jun jun Jul : Videos
5.查看HDFS集群中的文件
[jun@master ~]$ hadoop fs -cat /test/input/jun.txt
This is the txt file.
[jun@master ~]$ hadoop fs -text /test/input/jun.txt
This is the txt file.
[jun@master ~]$ hadoop fs -tail /test/input/jun.txt
This is the txt file.
6.删除HDFS文件
[jun@master ~]$ hadoop fs -rm /test/input/jun.txt
Deleted /test/input/jun.txt
[jun@master ~]$ hadoop fs -ls /test/input
Found items
-rw-r--r-- jun supergroup -- : /test/input/jun.dat
7.也可以在slave节点上执行命令
[jun@slave0 ~]$ hadoop fs -ls /test/input
Found items
-rw-r--r-- jun supergroup -- : /test/input/jun.dat
二、在Hadoop集群中运行程序
Hadoop安装文件中有一个MapReduce示例程序,该程序用来计算圆周率pi的Java程序包,
参数说明:pi(类名)、10(Map次数)、10(随机生成点的次数)
[jun@master ~]$ hadoop jar /home/jun/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8..jar pi
Number of Maps =
Samples per Map =
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Wrote input for Map #
Starting Job
// :: INFO client.RMProxy: Connecting to ResourceManager at master/192.168.1.100:
// :: INFO input.FileInputFormat: Total input files to process :
// :: INFO mapreduce.JobSubmitter: number of splits:
// :: INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1532226440522_0001
// :: INFO impl.YarnClientImpl: Submitted application application_1532226440522_0001
// :: INFO mapreduce.Job: The url to track the job: http://master:18088/proxy/application_1532226440522_0001/
// :: INFO mapreduce.Job: Running job: job_1532226440522_0001
// :: INFO mapreduce.Job: Job job_1532226440522_0001 running in uber mode : false
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: Job job_1532226440522_0001 completed successfully
// :: INFO mapreduce.Job: Counters:
File System Counters
FILE: Number of bytes read=
FILE: Number of bytes written=
FILE: Number of read operations=
FILE: Number of large read operations=
FILE: Number of write operations=
HDFS: Number of bytes read=
HDFS: Number of bytes written=
HDFS: Number of read operations=
HDFS: Number of large read operations=
HDFS: Number of write operations=
Job Counters
Launched map tasks=
Launched reduce tasks=
Data-local map tasks=
Total time spent by all maps in occupied slots (ms)=
Total time spent by all reduces in occupied slots (ms)=
Total time spent by all map tasks (ms)=
Total time spent by all reduce tasks (ms)=
Total vcore-milliseconds taken by all map tasks=
Total vcore-milliseconds taken by all reduce tasks=
Total megabyte-milliseconds taken by all map tasks=
Total megabyte-milliseconds taken by all reduce tasks=
Map-Reduce Framework
Map input records=
Map output records=
Map output bytes=
Map output materialized bytes=
Input split bytes=
Combine input records=
Combine output records=
Reduce input groups=
Reduce shuffle bytes=
Reduce input records=
Reduce output records=
Spilled Records=
Shuffled Maps =
Failed Shuffles=
Merged Map outputs=
GC time elapsed (ms)=
CPU time spent (ms)=
Physical memory (bytes) snapshot=
Virtual memory (bytes) snapshot=
Total committed heap usage (bytes)=
Shuffle Errors
BAD_ID=
CONNECTION=
IO_ERROR=
WRONG_LENGTH=
WRONG_MAP=
WRONG_REDUCE=
File Input Format Counters
Bytes Read=
File Output Format Counters
Bytes Written=
Job Finished in 88.689 seconds
Estimated value of Pi is 3.20000000000000000000
最后可以看到,得到的结果近似为3.2。
HDFS基本命令与Hadoop MapReduce程序的执行的更多相关文章
- 使用Python实现Hadoop MapReduce程序
转自:使用Python实现Hadoop MapReduce程序 英文原文:Writing an Hadoop MapReduce Program in Python 根据上面两篇文章,下面是我在自己的 ...
- 简单的java Hadoop MapReduce程序(计算平均成绩)从打包到提交及运行
[TOC] 简单的java Hadoop MapReduce程序(计算平均成绩)从打包到提交及运行 程序源码 import java.io.IOException; import java.util. ...
- [python]使用python实现Hadoop MapReduce程序:计算一组数据的均值和方差
这是参照<机器学习实战>中第15章“大数据与MapReduce”的内容,因为作者写作时hadoop版本和现在的版本相差很大,所以在Hadoop上运行python写的MapReduce程序时 ...
- 用Python语言写Hadoop MapReduce程序Writing an Hadoop MapReduce Program in Python
In this tutorial I will describe how to write a simple MapReduce program for Hadoop in the Python pr ...
- Python实现Hadoop MapReduce程序
1.概述 Hadoop Streaming提供了一个便于进行MapReduce编程的工具包,使用它可以基于一些可执行命令.脚本语言或其他编程语言来实现Mapper和 Reducer,从而充分利用Had ...
- Intellij idea开发Hadoop MapReduce程序
1.首先下载一个Hadoop包,仅Hadoop即可. http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.6.0/hadoop-2.6.0 ...
- Hadoop MapReduce程序中解决第三方jar包问题方案
hadoop怎样提交多个第三方jar包? 方案1:把所有的第三方jar和自己的class打成一个大的jar包,这种方案显然笨拙,而且更新升级比较繁琐. 方案2: 在你的project里面建立一个lib ...
- hadoop——在命令行下编译并运行map-reduce程序 2
hadoop map-reduce程序的编译需要依赖hadoop的jar包,我尝试javac编译map-reduce时指定-classpath的包路径,但无奈hadoop的jar分布太散乱,根据自己 ...
- hadoop-初学者写map-reduce程序中容易出现的问题 3
1.写hadoop的map-reduce程序之前所必须知道的基础知识: 1)hadoop map-reduce的自带的数据类型: Hadoop提供了如下内容的数据类型,这些数据类型都实现了Writab ...
随机推荐
- django查询表记录的十三种方法
django查询表记录的十三种方法 all() 结果为queryset类型 >>> models.Book.objects.all() <QuerySet [<Book: ...
- Java Map知识点
1.遍历 java遍历Map的方式有多种,一下以代码示例来说明使用: Map<String, String> tmap = new HashMap<String, String> ...
- Actor 模型中的通信模式
在 Actor 模型中所有的 Actor 之间有且只有一种通信模式,那就是 tell 的方式,也就是 fire and forget 的方式.但是在实际的开发过程中工程师们逐渐总结出了一些常用的通信模 ...
- thinkphp5 模型表关联
student 表 外键 grade_idgrade 表主键 id在 模型中student表关联方法public function Grade(){ return $this->hasOne(' ...
- jq中attr()和prop() 属性的区别
query1.6中新加了一个方法prop(),一直没用过它,官方解释只有一句话:获取在匹配的元素集中的第一个元素的属性值. 大家都知道有的浏览器只要写disabled,checked就可以了,而有的要 ...
- B/S 端构建的基于 WebGL 3D 可视化档案馆管理系统
前言 档案管理系统是通过建立统一的标准以规范整个文件管理,包括规范各业务系统的文件管理的完整的档案资源信息共享服务平台,主要实现档案流水化采集功能.为企事业单位的档案现代化管理,提供完整的解决方案,档 ...
- 痞子衡嵌入式:飞思卡尔i.MX RTyyyy系列MCU硬件那些事(2.1)- 玩转板载OpenSDA,Freelink调试器
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是飞思卡尔i.MX RTyyyy系列EVK上板载调试器的用法. 本文是i.MXRT硬件那些事系列第二篇,第一篇痞子衡给大家整体介绍了i.M ...
- springboot配置ehcache2.X缓存(@Cacheable等注解和手动操作缓存的工具类 支持element粒度的时间设置)
本文只写出一些注意事项和源码,请善用官方文档~ 注解实现 @Cacheable @CachePut @CacheEvit 启动类上加@EnableCaching就可以开启缓存 由文档可知,自动检测缓存 ...
- ActiveMQ学习总结------原生实战操作(下)03
本篇将继续延续上一篇的内容,作为知识补充篇,为接下来我们学习spring整合ActiveMQ打好基础 本篇主要学习内容: 1.ActiveMQ 队列服务监听 2.ActiveMQ Topic模型 回顾 ...
- 原生js动态创建、获取、删除属性的几种方式
1.创建属性 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <ti ...