【问题标题】:A hadoop job complete without map and reduce on a Hadoop Cluster( one namenode ,12 datanode)在 Hadoop 集群(一个名称节点,12 个数据节点)上完成一个没有映射和减少的 hadoop 作业
【发布时间】:2011-06-11 02:26:18
【问题描述】:

我写了一个hadoop程序并在一台机器上运行它,它运行良好。 但是当我将它迁移到集群(一个namenode,12个datanode)时遇到了以下问题(job没有启动并在map启动后立即完成)

命令在终端上运行:

hadoop jar VOConeSearch.jar 输入输出 142.82 -3.32 1

(这里input是hdfs中的一个目录供输入,output是程序写入的hdfs目录,执行前hdfs中没有输出目录,142.82,-3.32,1是三个额外参数)

集群信息
当我运行程序时,输入目录包含 167537 个文件

11/06/11 09:33:49 INFO security.Groups: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000
11/06/11 09:33:50 WARN conf.Configuration: mapred.task.id is deprecated. Instead, use mapreduce.task.attempt.id
11/06/11 09:33:50 WARN mapreduce.JobSubmitter: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
11/06/11 09:33:57 INFO input.FileInputFormat: Total input paths to process : 167537
11/06/11 09:37:36 WARN conf.Configuration: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
11/06/11 09:37:36 INFO mapreduce.JobSubmitter: number of splits:1
11/06/11 09:37:36 INFO mapreduce.JobSubmitter: adding the following namenodes' delegation tokens:null
11/06/11 09:37:36 INFO mapreduce.Job: Running job: job_201106081653_0011
11/06/11 09:37:37 INFO mapreduce.Job:  map 0% reduce 0%
11/06/11 09:37:37 INFO mapreduce.Job: Job complete: job_201106081653_0011
11/06/11 09:37:37 INFO mapreduce.Job: Counters: 4
    Job Counters 
        Total time spent by all maps waiting after reserving slots (ms)=0
        Total time spent by all reduces waiting after reserving slots (ms)=0
        SLOTS_MILLIS_MAPS=0
        SLOTS_MILLIS_REDUCES=0

似乎作业在 0 秒内完成,但 hdfs 中没有输出目录。同一个程序在一台机器上运行(namenode,datanode在同一台机器上)但是(hdfs)输入目录中只有一个文件。

输入目录中有一个文件的单个节点信息

11/06/11 10:07:54 INFO security.Groups: Group mapping
impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000
11/06/11 10:07:54 WARN conf.Configuration: mapred.task.id is deprecated. Instead, use
mapreduce.task.attempt.id
11/06/11 10:07:54 WARN mapreduce.JobSubmitter: Use GenericOptionsParser for parsing
the arguments. Applications should implement Tool for the same.
11/06/11 10:07:54 INFO input.FileInputFormat: Total input paths to process : 1
11/06/11 10:07:54 WARN conf.Configuration: mapred.map.tasks is deprecated. Instead,
use mapreduce.job.maps
11/06/11 10:07:54 INFO mapreduce.JobSubmitter: number of splits:1
11/06/11 10:07:55 INFO mapreduce.JobSubmitter: adding the following namenodes'
delegation tokens:null
11/06/11 10:07:55 INFO mapreduce.Job: Running job: job_201106111004_0001
11/06/11 10:07:56 INFO mapreduce.Job:  map 0% reduce 0%
11/06/11 10:08:11 INFO mapreduce.Job:  map 100% reduce 0%
11/06/11 10:08:17 INFO mapreduce.Job:  map 100% reduce 100%
11/06/11 10:08:19 INFO mapreduce.Job: Job complete: job_201106111004_0001
11/06/11 10:08:19 INFO mapreduce.Job: Counters: 33
    FileInputFormatCounters
        BYTES_READ=66580278
    FileSystemCounters
        FILE_BYTES_READ=6562
        FILE_BYTES_WRITTEN=13156
        HDFS_BYTES_READ=66580392
        HDFS_BYTES_WRITTEN=6941
    Shuffle Errors
        BAD_ID=0
        CONNECTION=0
        IO_ERROR=0
        WRONG_LENGTH=0
        WRONG_MAP=0
        WRONG_REDUCE=0
    Job Counters 
        Data-local map tasks=1
        Total time spent by all maps waiting after reserving slots (ms)=0
        Total time spent by all reduces waiting after reserving slots (ms)=0
        SLOTS_MILLIS_MAPS=8744
        SLOTS_MILLIS_REDUCES=3189
        Launched map tasks=1
        Launched reduce tasks=1
    Map-Reduce Framework
        Combine input records=0
        Combine output records=0
        Failed Shuffles=0
        GC time elapsed (ms)=867
        Map input records=118249
        Map output bytes=6512
        Map output records=11
        Merged Map outputs=1
        Reduce input groups=1
        Reduce input records=11
        Reduce output records=11
        Reduce shuffle bytes=6562
        Shuffled Maps =1
        Spilled Records=22
        SPLIT_RAW_BYTES=114

hadoop 程序的一部分

public static void main(String[] args) throws Exception {

    if(args.length != 5)
    {
        System.out.println("Usage : HadoopTest <input path> <output path> <ra> <dec> <sr>");
        System.exit(-1);
    }
    
    
    Job job = new Job();
    
    job.setJarByClass(HadoopTest.class);
    Configuration conf = job.getConfiguration();
    
    if(!isDouble(args[2])||!isDouble(args[3])||!isDouble(args[4]))
    {
        System.out.println("RA DEC SR should be real number");
        System.exit(-1);
    }
    
    DefaultStringifier.store(conf, new DoubleWritable(Double.parseDouble(args[2])), "ra");
    DefaultStringifier.store(conf, new DoubleWritable(Double.parseDouble(args[3])), "dec");
    DefaultStringifier.store(conf, new DoubleWritable(Double.parseDouble(args[4])), "sr");
    
    
    FileInputFormat.addInputPath(job,new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    
    job.setMapperClass(ConeSearchMap.class);
    job.setMapOutputKeyClass(ScircleWritableComparable.class);
    job.setMapOutputValueClass(Text.class);
    
    job.setReducerClass(ConeSearchReduce.class);
    
    job.setOutputKeyClass(ScircleWritableComparable.class);
    job.setOutputValueClass(Text.class);
    
    System.exit(job.waitForCompletion(true)? 0 : 1);
}

【问题讨论】:

  • 当您在 Web 界面上查看您的工作时,您是否看到任何地图故障或其他什么?
  • 我们应该如何访问您的主文件?
  • 我看到web界面,发现job显示map 100%,reduce 100%,但是说是FAILED。在详细页面所有列都是0(Setup,Map,Reduce ,清理)。点击“分析此作业”后,它回显“没有可用的分析,因为作业未完成”。但实际上工作完成了。
  • 当您单击作业时,您应该会在第一个表中看到一列显示“失败/终止的任务尝试”。如果您看到任何失败的尝试(/ 之前的数字...),请单击该数字,告诉我们它是 map 还是 reduce 任务,并将错误消息粘贴到您的问题中。
  • 实际上,您是否看到任何个失败的任务,或者作业在开始任何任务之前就失败了?

标签: java hadoop jobs


【解决方案1】:

想法是在你的工作对象中设置输入格式:

   SequenceFileInputFormat.addInputPath(job, in);
   SequenceFileOutputFormat.setOutputPath(job, out);
   job.setInputFormatClass(SequenceFileInputFormat.class);
   job.setOutputFormatClass(SequenceFileOutputFormat.class);

因此,您应该将其替换为 FileInputFormat 的具体子类,例如 TextFileInputFormatSequenceFileInputFormat

你的输出也一样。

【讨论】:

  • 非常感谢。TextInputFormat 有效,但 SequenceFileInputFormat 无效。 Hadoop说hdfs中的文件不是序列文件。
  • 我使用带有较小文件(7897 个文件)的 TextInputFormat 运行我的程序,并且该作业运行良好,但是该作业在使用较大文件(167537 个文件)运行时遇到了同样的问题(上述问题)。所以我想也许它还有其他问题。
  • 你想要什么文件?我可以发到你的邮箱吗?
  • 我不想要任何文件,@ajduff574 想要一些东西。我不知道为什么它不适用于这么多文件。那你为什么不分工呢?
  • 我想过这个问题,但是开始一份新工作需要很多时间。我使用 hadoop 来减少搜索大规模数据的时间。分解工作会增加时间。但也许我必须这样做。也许hadoop一次不能处理太多的文件。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2016-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多