目录
1、准备数据文件
word1.txt
i love the world
word2.txt
i love the world , hello ni hao
2、把文件上传到HDFS上
hadoop fs -mkdir /input
hadoop fs -put word1.txt /input
hadoop fs -put word2.txt /input
3、执行命令
hadoop jar /export/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input /output
输出日志:
[root@node1 ~]# hadoop jar /export/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input /output
18/09/09 09:14:48 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
18/09/09 09:14:48 INFO client.RMProxy: Connecting to ResourceManager at node1/192.168.254.101:8032
18/09/09 09:14:49 INFO input.FileInputFormat: Total input paths to process : 2
18/09/09 09:14:49 INFO mapreduce.JobSubmitter: number of splits:2
18/09/09 09:14:49 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1536498642048_0001
18/09/09 09:14:50 INFO impl.YarnClientImpl: Submitted application application_1536498642048_0001
18/09/09 09:14:50 INFO mapreduce.Job: The url to track the job: http://node1:8088/proxy/application_1536498642048_0001/
18/09/09 09:14:50 INFO mapreduce.Job: Running job: job_1536498642048_0001
18/09/09 09:14:58 INFO mapreduce.Job: Job job_1536498642048_0001 running in uber mode : false
18