hadoop(二)基本使用

使用前修改 C:\Windows\System32\drivers\etc 下的host文件(不修改会导致部分功能无法使用)

加入

192.168.116.16 hadoop1



进入/share/hadoop/mapreduce

会发现hadoop-mapreduce-examples-2.4.1.jar这个jar包,后续操作都依赖这个jar包


1.wordcount统计单词出现次数

vi test.txt

hello tom
hello   world
hello angelababy

hadoop fs -mkdir /wordcount

hadoop fs -mkdir /wordcount/input

hadoop fs -put test.txt /wordcount/input(hadoop fs -put hdfs://hadoop1:9000/wordcount/input/test.txt)

去http://hadoop1:50070查看上传的文件

hadoop jar hadoop-mapreduce-examples-2.4.1.jar wordcount /wordcount/input /wordcount/output

查看output文件夹里的统计结果

1.下载文件

2.用命令

hadoop fs -ls /wordcount/output

-rw-r--r--   1 hadoop supergroup          0 2018-03-24 23:34 /wordcount/output/_SUCCESS
-rw-r--r--   1 hadoop supergroup         35 2018-03-24 23:34 /wordcount/output/part-r-00000

hadoop fs -cat /wordcount/output/part-r-00000

angelababy 1
hello 3
tom 1

world


2.其他命令

hadoop fs  查看所有命令

hadoop fs -ls /

hadoop fs -cat /

hadoop fs -mkdir /

hadoop fs -mv /

hadoop fs -put /

hadoop fs -get /

hadoop fs -rm -r -f /

hadoop fs -tail -f /

hadoop fs -du hdfs://hadoop1:9000 /    查看每个文件夹大小(hadoop1为虚拟机主机名)

hadoop fs -df -h hdfs://hadoop1:9000 /  查看磁盘大小及使用量

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值