运行的命令:
[root@node1 ~]# cat wc.txt 
hello tom 
andy joy 
hello rose 
hello joy 
mark andy 
hello tom 
andy rose 
hello joy
[root@node1 ~]# hdfs dfs -mkdir -p /wordcount/input
21/11/03 13:28:24 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[root@node1 ~]# hdfs dfs -put wc.txt /wordcount/input
21/11/03 13:28:47 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[root@node1 ~]# hdfs dfs -ls /wordcount/input
21/11/03 13:30:00 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 1 items
-rw-r--r--   2 root supergroup         87 2021-11-03 13:28 /wordcount/input/wc.txt
[root@node1 ~]# cd /opt/hadoop-2.6.5/share/hadoop/mapreduce/
[root@node1 mapreduce]# ll
total 4880
-rw-rw-r-- 1 1000 1000  526732 Oct  3  2016 hadoop-mapreduce-client-app-2.6.5.jar
-rw-rw-r-- 1 1000 1000  686773 Oct  3  2016 hadoop-mapreduce-client-common-2.6.5.jar
-rw-rw-r-- 1 1000 1000 1535776 Oct  3  2016 hadoop-mapreduce-client-core-2.6.5.jar
-rw-rw-r-- 1 1000 1000  259326 Oct  3  2016 hadoop-mapreduce-client-hs-2.6.5.jar
-rw-rw-r-- 1 1000 1000   27489 Oct  3  2016 hadoop-mapreduce-client-hs-plugins-2.6.5.jar
-rw-rw-r-- 1 1000 1000   61309 Oct  3  2016 hadoop-mapreduce-client-jobclient-2.6.5.jar
-rw-rw-r-- 1 1000 1000 1514166 Oct  3  2016 hadoop-mapreduce-client-jobclient-2.6.5-tests.jar
-rw-rw-r-- 1 1000 1000   67762 Oct  3  2016 hadoop-mapreduce-client-shuffle-2.6.5.jar
-rw-rw-r-- 1 1000 1000  292710 Oct  3  2016 hadoop-mapreduce-examples-2.6.5.jar
drwxrwxr-x 2 1000 1000    4096 Oct  3  2016 lib
drwxrwxr-x 2 1000 1000    4096 Oct  3  2016 lib-examples
drwxrwxr-x 2 1000 1000    4096 Oct  3  2016 sources
[root@node1 mapreduce]# hadoop jar hadoop-mapreduce-examples-2.6.5.jar wordcount /wordcount/input /wordcount/output
21/11/03 13:31:43 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
21/11/03 13:31:48 INFO input.FileInputFormat: Total input paths to process : 1
21/11/03 13:31:48 INFO mapreduce.JobSubmitter: number of splits:1
21/11/03 13:31:49 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1635917251344_0001
21/11/03 13:31:50 INFO impl.YarnClientImpl: Submitted application application_1635917251344_0001
21/11/03 13:31:50 INFO mapreduce.Job: The url to track the job: http://node3:8088/proxy/application_1635917251344_0001/
21/11/03 13:31:50 INFO mapreduce.Job: Running job: job_1635917251344_0001
21/11/03 13:32:07 INFO mapreduce.Job: Job job_1635917251344_0001 running in uber mode : false
21/11/03 13:32:07 INFO mapreduce.Job:  map 0% reduce 0%
21/11/03 13:32:23 INFO mapreduce.Job:  map 100% reduce 0%
21/11/03 13:32:33 INFO mapreduce.Job:  map 100% reduce 100%
21/11/03 13:32:33 INFO mapreduce.Job: Job job_1635917251344_0001 completed successfully
21/11/03 13:32:33 INFO mapreduce.Job: Counters: 49
  File System Counters
    FILE: Number of bytes read=71
    FILE: Number of bytes written=218919
    FILE: Number of read operations=0
    FILE: Number of large read operations=0
    FILE: Number of write operations=0
    HDFS: Number of bytes read=191
    HDFS: Number of bytes written=41
    HDFS: Number of read operations=6
    HDFS: Number of large read operations=0
    HDFS: Number of write operations=2
  Job Counters 
    Launched map tasks=1
    Launched reduce tasks=1
    Data-local map tasks=1
    Total time spent by all maps in occupied slots (ms)=13217
    Total time spent by all reduces in occupied slots (ms)=5760
    Total time spent by all map tasks (ms)=13217
    Total time spent by all reduce tasks (ms)=5760
    Total vcore-milliseconds taken by all map tasks=13217
    Total vcore-milliseconds taken by all reduce tasks=5760
    Total megabyte-milliseconds taken by all map tasks=13534208
    Total megabyte-milliseconds taken by all reduce tasks=5898240
  Map-Reduce Framework
    Map input records=8
    Map output records=16
    Map output bytes=144
    Map output materialized bytes=71
    Input split bytes=104
    Combine input records=16
    Combine output records=6
    Reduce input groups=6
    Reduce shuffle bytes=71
    Reduce input records=6
    Reduce output records=6
    Spilled Records=12
    Shuffled Maps =1
    Failed Shuffles=0
    Merged Map outputs=1
    GC time elapsed (ms)=315
    CPU time spent (ms)=3460
    Physical memory (bytes) snapshot=293687296
    Virtual memory (bytes) snapshot=4126777344
    Total committed heap usage (bytes)=140374016
  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=87
  File Output Format Counters 
    Bytes Written=41
[root@node1 mapreduce]# hdfs dfs -ls /wordcount/output
21/11/03 13:41:39 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 2 items
-rw-r--r--   2 root supergroup          0 2021-11-03 13:32 /wordcount/output/_SUCCESS
-rw-r--r--   2 root supergroup         41 2021-11-03 13:32 /wordcount/output/part-r-00000
[root@node1 mapreduce]# hdfs dfs -cat /wordcount/output/part-r-00000
21/11/03 13:42:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
andy  3
hello 5
joy 3
mark  1
rose  2
tom 2
[root@node1 mapreduce]# hdfs dfs -get /wordcount/output/part-r-00000
21/11/03 13:44:15 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[root@node1 mapreduce]# ls
hadoop-mapreduce-client-app-2.6.5.jar     hadoop-mapreduce-client-hs-2.6.5.jar          hadoop-mapreduce-client-jobclient-2.6.5-tests.jar  lib           sources
hadoop-mapreduce-client-common-2.6.5.jar  hadoop-mapreduce-client-hs-plugins-2.6.5.jar  hadoop-mapreduce-client-shuffle-2.6.5.jar          lib-examples
hadoop-mapreduce-client-core-2.6.5.jar    hadoop-mapreduce-client-jobclient-2.6.5.jar   hadoop-mapreduce-examples-2.6.5.jar                part-r-00000
[root@node1 mapreduce]# cat part-r-00000 
andy  3
hello 5
joy 3
mark  1
rose  2
tom 2*input:是 hdfs 文件系统中数据所在的目录
 *ouput:是 hdfs 中不存在的目录,mr 程序运行的结果会输出到该目录
 /_SUCCESS:是信号/标志文件
 /part-r-00000:是 reduce 输出的数据文件
 r:reduce 的意思,00000 是对应的 reduce 编号,多个 reduce 会有多个数据文件
                
                










