mapreduce和hcatalog集成无法使用mysql元存储

aiazj4mn  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(201)

环境:HDP2.3沙盒
问题:我在配置单元中创建了一个只有2列的表。现在我想用hcatalog集成在mr代码中阅读这个。mr作业无法从mysql元存储读取表。出于某种原因,它使用了derby,因此失败了,并显示“table not found”消息。
作业客户端代码:

public class HCatalogMRJob extends Configured implements Tool {

   public int run(String[] args) throws Exception {
        Configuration conf = getConf();
        args = new GenericOptionsParser(conf, args).getRemainingArgs();
        String inputTableName = args[0];
        String outputTableName = args[1];
        String dbName = null;
        Job job = new Job(conf, "HCatalogMRJob");
        HCatInputFormat.setInput(job, dbName, inputTableName);
        job.setInputFormatClass(HCatInputFormat.class);
        job.setJarByClass(HCatalogMRJob.class);
        job.setMapperClass(HCatalogMapper.class);
        job.setReducerClass(HCatalogReducer.class);
        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(WritableComparable.class);
        job.setOutputValueClass(DefaultHCatRecord.class);
        HCatOutputFormat.setOutput(job, OutputJobInfo.create(dbName, outputTableName, null));
        HCatSchema s = HCatOutputFormat.getTableSchema(conf);
        System.err.println("INFO: output schema explicitly set for writing:"
                + s);
        HCatOutputFormat.setSchema(job, s);
        job.setOutputFormatClass(HCatOutputFormat.class);
        return (job.waitForCompletion(true) ? 0 : 1);
    }
    public static void main(String[] args) throws Exception {
        int exitCode = ToolRunner.run(new HCatalogMRJob(), args);
        System.exit(exitCode);
    }
}

作业运行命令:

hadoop jar mr-hcat.jar input_table out_table

在运行这个命令之前,我已经使用hadoop\u classpath变量在类路径中设置了必要的hcatalog、hive jar。
问题:
现在,如何正确使用hive-site.xml?
我试着用上面提到的hadoop\u类路径在类路径中设置这个,但是还是失败了。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题