Map JobConf中未设置输出目录

Map JobConf中未设置输出目录,map,hadoop,mapreduce,Map,Hadoop,Mapreduce,我在下面提到一个简单的mapR程序的驱动程序代码 import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapred.JobClient; import org.apache.hadoop.mapred.JobConf; import org.apa

我在下面提到一个简单的mapR程序的驱动程序代码

   import org.apache.hadoop.fs.Path;
   import org.apache.hadoop.io.IntWritable;
   import org.apache.hadoop.io.Text;
   import org.apache.hadoop.mapred.JobClient;
   import org.apache.hadoop.mapred.JobConf;
   import org.apache.hadoop.mapreduce.Job;
   import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
   import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

  @SuppressWarnings("deprecation")
  public class CsvParserDriver {
      @SuppressWarnings("deprecation")
      public static void main(String[] args) throws Exception
      {
          if(args.length != 2)
          {
              System.out.println("usage: [input] [output]");
              System.exit(-1);
          }

          JobConf conf = new JobConf(CsvParserDriver.class);
          Job job = new Job(conf);
          conf.setJobName("CsvParserDriver");

          FileInputFormat.setInputPaths(job, new Path(args[0]));
          FileOutputFormat.setOutputPath(job, new Path(args[1]));

          conf.setMapperClass(CsvParserMapper.class);
          conf.setMapOutputKeyClass(IntWritable.class);
          conf.setMapOutputValueClass(Text.class);

          conf.setReducerClass(CsvParserReducer.class);
          conf.setOutputKeyClass(Text.class);
          conf.setOutputValueClass(Text.class);

          conf.set("splitNode","NUM_AE");

          JobClient.runJob(conf);
      }
  }
我正在使用下面的命令运行我的代码

hadoop jar CsvParser.jar CsvParserDriver /user/sritamd/TestData /user/sritamd/output
(创建上述命令中所有相应的JAR和目录)

我得到的错误为

Exception in thread "main" org.apache.hadoop.mapred.InvalidJobConfException: Output directory not set in JobConf.

您没有像ApacheHadoop教程中指定的那样创建HDFS输入和输出目录


如果要使用本地目录
file:///user/sritamd/TestData
-添加FS前缀。

我认为您需要将输入和输出目录设置为conf,而不是作业,例如:

FileInputFormat.setInputPaths(conf, new Path(args[0]));

FileOutputFormat.setOutputPath(conf, new Path(args[1]));
试试这个

 Configuration configuration = new Configuration();
 Job job = new Job(configuration, "MyConfig");
然后


您的HDFS文件系统可能无法创建。您需要首先格式化给定的目录,并且该目录可以用作Hadoop文件的输入和输出

/usr/local/hadoop/bin/hadoop namenode-格式

使用链接:-


并遵循每一步

这可能是由旧API和新API引起的

这是我的新作业API,用于进行配置

步骤1:导入新的API库

import org.apache.hadoop.mapreduce.Job
步骤2:通过新的API作业进行配置

val job = Job.getInstance(conf)
job.getConfiguration.set(TableOutputFormat.OUTPUT_TABLE, tableName)
job.setOutputFormatClass(classOf[TableOutputFormat[Put]])

希望这能对您有所帮助。

如果您在标准模式(无集群)下运行hadoop来测试代码,您不需要在输出路径中添加fs前缀。您可以初始化作业并设置路径。以下代码应该可以工作(确保您使用的是Job(来自org.apache.hadoop.mapreduce.Job)或org.apache.hadoop.mapred.JobConf)


我也有同样的问题,但已经解决了。我使用了
job.waitForCompletion(true)
,这在使用
saveAsNewAPIHadoopFile(…)
时导致hbase上的spark崩溃 您不应该等待作业,因为它使用的是旧的Hadoop api而不是新的api
  • 首先确保您的目录不存在。如果存在,删除它
  • 第二步,在Eclipse中运行您的代码,如果它运行正常并发出
    ArrayOutofBounds
    警告
  • 否则,请检查插入的库,确保插入所有客户端库或检查类是否在包中


    如果上述所有条件都满足,您的作业将执行。

    假设我想使用自定义记录编写器写入其他数据库(不是mysql,因为记录编写器已经在hadoop中),那么应该如何配置以删除此异常?
    val job = Job.getInstance(conf)
    job.getConfiguration.set(TableOutputFormat.OUTPUT_TABLE, tableName)
    job.setOutputFormatClass(classOf[TableOutputFormat[Put]])
    
            Job job = new Job();
            job.setJobName("Job Name");
            job.setJarByClass(MapReduceJob.class);
    
            FileInputFormat.setInputPaths(job,new Path(args[0]));
            FileOutputFormat.setOutputPath(job,new Path(args[1]));
    
            job.setMapperClass(MaxTemperatureMapper.class);
            job.setReducerClass(MaxTemperatureReducer.class);
    
            job.setOutputKeyClass(Text.class);
            job.setOutputValueClass(IntWritable.class);
    
            System.exit(job.waitForCompletion(true)? 0:1);