使用前修改 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 1
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 / 查看磁盘大小及使用量