1. 程式人生 > >wordcount報錯:org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist:

wordcount報錯:org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist:

Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://192.168.25.128:9000/export/yang/log.1
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:323)
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:265)
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:387)
    at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:301)
    at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:318)
    at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:196)
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1290)
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1287)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:1287)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1308)
    at hadoop1.WordCount.main(WordCount.java:53)

當本人在執行,Hadoop叢集自帶的wordcount例項的時候,報錯內容為輸入路徑不存在,在網上找了很久沒有解決,最後發現是因為我建立的log.1是在本地建立的,並沒有上傳到hdfs叢集中,所以在執行的時候會報錯,解決的辦法是:執行命令:

[[email protected] ~]# hadoop fs -put log.1 /       #(將log.1檔案上傳到/目錄下)

操作之後可以再次執行命令:

[[email protected] ~]# hadoop jar /export/servers/hadoop/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /1.log /result

執行結果如下:

18/11/12 14:55:18 INFO client.RMProxy: Connecting to ResourceManager at /192.168.25.128:8032
18/11/12 14:55:19 INFO input.FileInputFormat: Total input paths to process : 1
18/11/12 14:55:19 INFO mapreduce.JobSubmitter: number of splits:1
18/11/12 14:55:19 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1542005142273_0001
18/11/12 14:55:20 INFO impl.YarnClientImpl: Submitted application application_1542005142273_0001
18/11/12 14:55:20 INFO mapreduce.Job: The url to track the job: http://master:8088/proxy/application_1542005142273_0001/
18/11/12 14:55:20 INFO mapreduce.Job: Running job: job_1542005142273_0001
18/11/12 14:55:32 INFO mapreduce.Job: Job job_1542005142273_0001 running in uber mode : false
18/11/12 14:55:32 INFO mapreduce.Job:  map 0% reduce 0%
18/11/12 14:55:43 INFO mapreduce.Job:  map 100% reduce 0%
18/11/12 14:55:51 INFO mapreduce.Job:  map 100% reduce 100%
18/11/12 14:55:51 INFO mapreduce.Job: Job job_1542005142273_0001 completed successfully
18/11/12 14:55:51 INFO mapreduce.Job: Counters: 49
        File System Counters
                FILE: Number of bytes read=312
                FILE: Number of bytes written=237571
                FILE: Number of read operations=0
                FILE: Number of large read operations=0
                FILE: Number of write operations=0
                HDFS: Number of bytes read=300
                HDFS: Number of bytes written=206
                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)=7544
                Total time spent by all reduces in occupied slots (ms)=5156
                Total time spent by all map tasks (ms)=7544
                Total time spent by all reduce tasks (ms)=5156
                Total vcore-milliseconds taken by all map tasks=7544
                Total vcore-milliseconds taken by all reduce tasks=5156
                Total megabyte-milliseconds taken by all map tasks=7725056
                Total megabyte-milliseconds taken by all reduce tasks=5279744
        Map-Reduce Framework
                Map input records=1
                Map output records=35
                Map output bytes=342
                Map output materialized bytes=312
                Input split bytes=97
                Combine input records=35
                Combine output records=25
                Reduce input groups=25
                Reduce shuffle bytes=312
                Reduce input records=25
                Reduce output records=25
                Spilled Records=50
                Shuffled Maps =1
                Failed Shuffles=0
                Merged Map outputs=1
                GC time elapsed (ms)=230
                CPU time spent (ms)=2110
                Physical memory (bytes) snapshot=306843648
                Virtual memory (bytes) snapshot=4163534848
                Total committed heap usage (bytes)=142278656
        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=203
        File Output Format Counters 
                Bytes Written=206

執行成功!