在hadoop-2.6.0-cdh5.15.1/share/hadoop/mapreduce路徑下有一個hadoop-mapreduce-examples-2.6.0-cdh5.15.1.jar文件 運行命令:hadoop jar hadoop-mapreduce-examples-2.6.0-cdh5.15.1.jar pi 2 3 然后在瀏覽器中輸入yarn的地址:ip:8088,在RUNNING下可以看到運行的作業:
查看控制臺輸出:
iie4bu@swarm-worker1:~/app/hadoop-2.6.0-cdh5.15.1/share/hadoop/mapreduce$ hadoop jar hadoop-mapreduce-examples-2.6.0-cdh5.15.1.jar pi 2 3
Number of Maps = 2
Samples per Map = 3
19/11/07 15:52:37 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Wrote input for Map #0
Wrote input for Map #1
Starting Job
19/11/07 15:52:38 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
19/11/07 15:52:39 INFO input.FileInputFormat: Total input paths to process : 2
19/11/07 15:52:39 INFO mapreduce.JobSubmitter: number of splits:2
19/11/07 15:52:39 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1573113153178_0001
19/11/07 15:52:40 INFO impl.YarnClientImpl: Submitted application application_1573113153178_0001
19/11/07 15:52:40 INFO mapreduce.Job: The url to track the job: http://swarm-worker1:8088/proxy/application_1573113153178_0001/
19/11/07 15:52:40 INFO mapreduce.Job: Running job: job_1573113153178_0001
19/11/07 15:52:48 INFO mapreduce.Job: Job job_1573113153178_0001 running in uber mode : false
19/11/07 15:52:48 INFO mapreduce.Job: map 0% reduce 0%
19/11/07 15:52:54 INFO mapreduce.Job: map 50% reduce 0%
19/11/07 15:52:55 INFO mapreduce.Job: map 100% reduce 0%
19/11/07 15:53:00 INFO mapreduce.Job: map 100% reduce 100%
19/11/07 15:53:00 INFO mapreduce.Job: Job job_1573113153178_0001 completed successfully
19/11/07 15:53:00 INFO mapreduce.Job: Counters: 49File System CountersFILE: Number of bytes read=50FILE: Number of bytes written=430365FILE: Number of read operations=0FILE: Number of large read operations=0FILE: Number of write operations=0HDFS: Number of bytes read=540HDFS: Number of bytes written=215HDFS: Number of read operations=11HDFS: Number of large read operations=0HDFS: Number of write operations=3Job Counters Launched map tasks=2Launched reduce tasks=1Data-local map tasks=2Total time spent by all maps in occupied slots (ms)=6933Total time spent by all reduces in occupied slots (ms)=3732Total time spent by all map tasks (ms)=6933Total time spent by all reduce tasks (ms)=3732Total vcore-milliseconds taken by all map tasks=6933Total vcore-milliseconds taken by all reduce tasks=3732Total megabyte-milliseconds taken by all map tasks=7099392Total megabyte-milliseconds taken by all reduce tasks=3821568Map-Reduce FrameworkMap input records=2Map output records=4Map output bytes=36Map output materialized bytes=56Input split bytes=304Combine input records=0Combine output records=0Reduce input groups=2Reduce shuffle bytes=56Reduce input records=4Reduce output records=0Spilled Records=8Shuffled Maps =2Failed Shuffles=0Merged Map outputs=2GC time elapsed (ms)=308CPU time spent (ms)=2610Physical memory (bytes) snapshot=942092288Virtual memory (bytes) snapshot=7986814976Total committed heap usage (bytes)=1810890752Shuffle ErrorsBAD_ID=0CONNECTION=0IO_ERROR=0WRONG_LENGTH=0WRONG_MAP=0WRONG_REDUCE=0File Input Format Counters Bytes Read=236File Output Format Counters Bytes Written=97
Job Finished in 21.985 seconds
Estimated value of Pi is 4.00000000000000000000
剛開始會執行Connecting to ResourceManager at /0.0.0.0:8032,首先連接到ResourceManager中。這就是一個最簡單的YARN作業
使用官方提供的例子 wordcount
在與上面同樣的路徑下執行命令: iie4bu@swarm-worker1:~/app/hadoop-2.6.0-cdh5.15.1/share/hadoop/mapreduce$ hadoop jar hadoop-mapreduce-examples-2.6.0-cdh5.15.1.jar wordcount /wc/input/test.txt /wc/output
在/wc/output/下可以看到輸出結果的文件:
iie4bu@swarm-worker1:~/app/hadoop-2.6.0-cdh5.15.1/share/hadoop/mapreduce$ hadoop fs -text /wc/output/part-r-00000
19/11/07 16:26:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Hello 1
haha 2
hello 3
meme 1
welcome 2
world 1
與50位技術專家面對面20年技術見證,附贈技術全景圖