【问题标题】:Getting Hbase Exception No regions passed获取 Hbase 异常未通过任何区域
【发布时间】:2014-12-01 10:33:41
【问题描述】:

嗨,我是 Hbase 新手,我正在尝试学习如何使用 MapReduce 将批量数据加载到 Hbase 表中

但我正在低于异常

线程“main”java.lang.IllegalArgumentException 中的异常:未传递任何区域 在 org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.writePartitions(HFileOutputFormat2.java:307) 在 org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.configurePartitioner(HFileOutputFormat2.java:527) 在 org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.configureIncrementalLoad(HFileOutputFormat2.java:391) 在 org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.configureIncrementalLoad(HFileOutputFormat2.java:356) 在 JobDriver.run(JobDriver.java:108) 在 org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) 在 org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84) 在 JobDriver.main(JobDriver.java:34) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:606) 在 org.apache.hadoop.util.RunJar.main(RunJar.java:212)

这是我的映射器代码

public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		
		
		System.out.println("Value in Mapper"+value.toString());
		String[] values = value.toString().split(",");
         byte[] row = Bytes.toBytes(values[0]);
         ImmutableBytesWritable k = new ImmutableBytesWritable(row);
         KeyValue kvProtocol = new KeyValue(row, "PROTOCOLID".getBytes(), "PROTOCOLID".getBytes(), values[1]
                         .getBytes());
         context.write(k, kvProtocol);
}

这是我的工作配置

public class JobDriver extends Configured implements Tool{

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		ToolRunner.run(new JobDriver(), args);
		System.exit(0);

	}

	@Override
	public int run(String[] arg0) throws Exception {
		// TODO Auto-generated method stub
		
		// HBase Configuration
		System.out.println("**********Starting Hbase*************");
				Configuration conf = HBaseConfiguration.create();
                Job job = new Job(conf, "TestHFileToHBase");
                job.setJarByClass(JobDriver.class);
                job.setOutputKeyClass(ImmutableBytesWritable.class);
                job.setOutputValueClass(KeyValue.class);
                job.setMapperClass(LoadMapper.class);
                job.setOutputFormatClass(HFileOutputFormat2.class);                
                HTable table = new HTable(conf, "kiran");
                FileInputFormat.addInputPath(job, new Path("hdfs://192.168.61.62:9001/sampledata.csv"));
                FileOutputFormat.setOutputPath(job, new Path("hdfs://192.168.61.62:9001/deletions_6.csv"));
                HFileOutputFormat2.configureIncrementalLoad(job, table);
                //System.exit(job.waitForCompletion(true) ? 0 : 1);
				return job.waitForCompletion(true) ? 0 : 1;
	}
}

谁能帮我解决这个异常。

【问题讨论】:

  • 你能分享一下你的 Mapper 的完整代码吗?你有减速机吗?

标签: hadoop mapreduce hbase


【解决方案1】:

您必须先创建表。你可以用下面的代码来做

//Create table and do pre-split
HTableDescriptor descriptor = new HTableDescriptor(
Bytes.toBytes(tableName)
);

descriptor.addFamily(
new HColumnDescriptor(Constants.COLUMN_FAMILY_NAME)
);

HBaseAdmin admin = new HBaseAdmin(config);

byte[] startKey = new byte[16];
Arrays.fill(startKey, (byte) 0);

byte[] endKey = new byte[16];
Arrays.fill(endKey, (byte)255);

admin.createTable(descriptor, startKey, endKey, REGIONS_COUNT);
admin.close();

或直接从 hbase shell 使用以下命令:

create 'kiran', 'colfam1'

由于startkeys列表为空导致异常:line 306

更多信息可以在here找到。

请注意,表名必须与您在代码中使用的表名相同 (kiran)。

【讨论】:

    猜你喜欢
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多