Hbase、Hive、Impala数据同步简单示例

Hbase +hive+impala数据同步简单示例

首先先在hbase创建表

hbase

hbase shell

list

scan 'TEST_INFO'

create 'TEST_INFO','d'

put ‘TEST_INFO’,’001’,’fields’,’VALUE’,

scan 'TEST_INFO'

Hive

hive创建外部表

show databases;

show tables;

CREATE EXTERNAL TABLE TEST_INFO(

 id string,field12 string,field13 string,field14 string, field15 string,field16 string, field17 string, field18 string, field19 string,field20 string,field21 string,field22 string,field23 string,field24 string,field25 string, field26 string,field27 string,field28 string, field29 string,field30 string, field31 string, field32 string,field33 string,field34 string,field35 string)

ROW FORMAT SERDE 'org.apache.hadoop.hive.hbase.HBaseSerDe'

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES ('serialization.format'='\t','hbase.columns.mapping'=':key, d:field12,d:field13,d:field14, d:field15, d:field16,d:field17, d:field18,d:field19, d:field20,d:field21, d:field22,d:field23, d:field24,d:field25, d:field26,d:field27, d:field28,d:field29, d:field30,d:field31, d:field32,d:field33, d:field34, d:field35','field.delim'='\t')

TBLPROPERTIES('hbase.table.name'='TEST_INFO');

 

hive> CREATE EXTERNAL TABLE TEST_INFO(

    >  id string,field12 string,field13 string,field14 string, field15 string,field16 string, field17 string, field18 string, field19 string,field20 string,field21 string,field22 string,field23 string,field24 string,field25 string, field26 string,field27 string,field28 string, field29 string,field30 string, field31 string, field32 string,field33 string,field34 string,field35 string)

    > ROW FORMAT SERDE 'org.apache.hadoop.hive.hbase.HBaseSerDe'

    > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

    > WITH SERDEPROPERTIES ('serialization.format'='\t','hbase.columns.mapping'=':key, d:field12,d:field13,d:field14, d:field15, d:field16,d:field17, d:field18,d:field19, d:field20,d:field21, d:field22,d:field23, d:field24,d:field25, d:field26,d:field27, d:field28,d:field29, d:field30,d:field31, d:field32,d:field33, d:field34, d:field35','field.delim'='\t')

    > TBLPROPERTIES('hbase.table.name'='TEST_INFO');

Hbase、Hive、Impala数据同步简单示例_第1张图片

hive> desc test_info;

Hbase、Hive、Impala数据同步简单示例_第2张图片

hive>select * from test_info;

impala

impala-shell

#同步hive ipmala

INVALIDATE METADATA; 

[cdh002:21000] > desc test_info;

Hbase、Hive、Impala数据同步简单示例_第3张图片

 #查看到映射HBase中表的结构:

[cdh002:21000] > select * from test_info;

Hbase、Hive、Impala数据同步简单示例_第4张图片


    

你可能感兴趣的:(大数据~HBase,大数据~Hive,大数据~Impala)