欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

提交官方MapReduce作业到YARN

程序员文章站 2024-02-22 12:11:53
...

环境

Hadoop使用版本:hadoop-2.6.0-cdh5.15.1

使用官方提供的例子 PI

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下可以看到运行的作业:
提交官方MapReduce作业到YARN
查看控制台输出:

aaa@qq.com:~/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: 49
	File System Counters
		FILE: Number of bytes read=50
		FILE: Number of bytes written=430365
		FILE: Number of read operations=0
		FILE: Number of large read operations=0
		FILE: Number of write operations=0
		HDFS: Number of bytes read=540
		HDFS: Number of bytes written=215
		HDFS: Number of read operations=11
		HDFS: Number of large read operations=0
		HDFS: Number of write operations=3
	Job Counters 
		Launched map tasks=2
		Launched reduce tasks=1
		Data-local map tasks=2
		Total time spent by all maps in occupied slots (ms)=6933
		Total time spent by all reduces in occupied slots (ms)=3732
		Total time spent by all map tasks (ms)=6933
		Total time spent by all reduce tasks (ms)=3732
		Total vcore-milliseconds taken by all map tasks=6933
		Total vcore-milliseconds taken by all reduce tasks=3732
		Total megabyte-milliseconds taken by all map tasks=7099392
		Total megabyte-milliseconds taken by all reduce tasks=3821568
	Map-Reduce Framework
		Map input records=2
		Map output records=4
		Map output bytes=36
		Map output materialized bytes=56
		Input split bytes=304
		Combine input records=0
		Combine output records=0
		Reduce input groups=2
		Reduce shuffle bytes=56
		Reduce input records=4
		Reduce output records=0
		Spilled Records=8
		Shuffled Maps =2
		Failed Shuffles=0
		Merged Map outputs=2
		GC time elapsed (ms)=308
		CPU time spent (ms)=2610
		Physical memory (bytes) snapshot=942092288
		Virtual memory (bytes) snapshot=7986814976
		Total committed heap usage (bytes)=1810890752
	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=236
	File 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

在与上面同样的路径下执行命令:
aaa@qq.com:~/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
提交官方MapReduce作业到YARN
在/wc/output/下可以看到输出结果的文件:

aaa@qq.com:~/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