问题:
在Windows系统下运行Hadoop MapReduce应用报错如下:
E:\EclipsePro\ssm\aa>hadoop jar target\aa-0.0.1-SNAPSHOT.jar /1.txt /out5
Exception in thread "main" java.io.IOException: Mkdirs failed to create C:\Users\ADMINI~1\AppData\Local\Temp\hadoop-unjar3611278334038571997\META-INF\license
at org.apache.hadoop.util.RunJar.ensureDirectory(RunJar.java:128)
at org.apache.hadoop.util.RunJar.unJar(RunJar.java:104)
at org.apache.hadoop.util.RunJar.unJar(RunJar.java:81)
at org.apache.hadoop.util.RunJar.run(RunJar.java:209)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
aa-0.0.1-SNAPSHOT.jar为自己编写并打包得到的MapReduce WordCount应用程序,参考:MapReduce WordCount应用 。
解决办法:
修改pom.xml文件
在<configuration>和</configuration>之间添加
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/LICENSE*</exclude>
<exclude>license/*</exclude>
</excludes>
</filter>
</filters>
修改后效果截图如下:
重新打包程序
mvn clean package
再次运行jar,成功如下:
E:\EclipsePro\ssm\aa>hadoop jar target\aa-0.0.1-SNAPSHOT.jar /1.txt /o1
19/10/20 23:39:14 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
19/10/20 23:39:15 WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
19/10/20 23:39:16 INFO input.FileInputFormat: Total input paths to process : 1
19/10/20 23:39:17 INFO mapreduce.JobSubmitter: number of splits:1
19/10/20 23:39:17 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1571582539006_0002
19/10/20 23:39:17 INFO impl.YarnClientImpl: Submitted application application_1571582539006_0002
19/10/20 23:39:17 INFO mapreduce.Job: The url to track the job: http://DESKTOP-EULLDM0:8088/proxy/application_1571582539006_0002/
19/10/20 23:39:17 INFO mapreduce.Job: Running job: job_1571582539006_0002
19/10/20 23:39:35 INFO mapreduce.Job: Job job_1571582539006_0002 running in uber mode : false
19/10/20 23:39:35 INFO mapreduce.Job: map 0% reduce 0%
19/10/20 23:39:40 INFO mapreduce.Job: map 100% reduce 0%
19/10/20 23:39:46 INFO mapreduce.Job: map 100% reduce 100%
19/10/20 23:39:56 INFO mapreduce.Job: Job job_1571582539006_0002 completed successfully
19/10/20 23:39:56 INFO mapreduce.Job: Counters: 49
File System Counters
FILE: Number of bytes read=55
FILE: Number of bytes written=238911
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=117
HDFS: Number of bytes written=25
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)=2658
Total time spent by all reduces in occupied slots (ms)=3281
Total time spent by all map tasks (ms)=2658
Total time spent by all reduce tasks (ms)=3281
Total vcore-milliseconds taken by all map tasks=2658
Total vcore-milliseconds taken by all reduce tasks=3281
Total megabyte-milliseconds taken by all map tasks=2721792
Total megabyte-milliseconds taken by all reduce tasks=3359744
Map-Reduce Framework
Map input records=2
Map output records=4
Map output bytes=41
Map output materialized bytes=55
Input split bytes=92
Combine input records=0
Combine output records=0
Reduce input groups=3
Reduce shuffle bytes=55
Reduce input records=4
Reduce output records=3
Spilled Records=8
Shuffled Maps =1
Failed Shuffles=0
Merged Map outputs=1
GC time elapsed (ms)=68
CPU time spent (ms)=1403
Physical memory (bytes) snapshot=435302400
Virtual memory (bytes) snapshot=592404480
Total committed heap usage (bytes)=295174144
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=25
File Output Format Counters
Bytes Written=25
完成! enjoy it!