1. 在hive-site.xml里面添加:
<property>
<name>hive.aux.jars.path</name>
<value>file:///usr/lib/hive/lib/hive-hbase-handler-0.9.0-cdh4.1.0.jar,file:///usr/lib/hbase/hbase-0.94.2-cdh4.2.0-security.jar,file:///usr/lib/zookeeper/zookeeper.jar</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>SVR2368HP360,SVR2369HP360,SVR2370HP360</value>
</property>
2. 创建hive里面对应hbase的表(相当于hive对hbase的视图):
CREATE EXTERNAL TABLE test_sqoop(
a string,
b string,
c string,
x string,
y string
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:b,cf:c,cf:x,cf:y")
TBLPROPERTIES("hbase.table.name" = "test_sqoop");
1. 创建hive avro文件格式表
CREATE TABLE test_avro
ROW FORMAT
SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
STORED AS
INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
TBLPROPERTIES ('avro.schema.literal'='{
"namespace": "testing.hive.avro.serde",
"name": "test_avro",
"type": "record",
"fields": [
{ "name":"a",
"type":"string",
"doc":"test a"},
{ "name":"b",
"type":"string",
"doc":"test b"},
{"name":"c",
"type":"string",
"doc":"test c"},
{"name":"x",
"type":"string",
"doc":"test d"},
{"name":"y",
"type":"string",
"doc:":"test e",
"default":"fishfingers and custard" }
]}');
2. hbase导入到hive:
insert overwrite table test_avro select * from test_sqoop;