HBase实战(3):使用HIVE SQL 操作分布式集群HBASE

使用HIVE  SQL操作分布式集群HBASE:

1,在Hive中创建HBase识别的表 

hive>     
    > 
    > CREATE EXTERNAL  TABLE hbase_hive_.....tion(rowkey string, info map)   
    > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   
    > WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:")   
    > TBLPROPERTIES ("hbase.table.name" = "db_r......._operation");  
OK
Time taken: 0.959 seconds

2,hive连接Hbase,查询数据:

root@master:~# jps
3808 Jps
3075 ResourceManager
3715 HRegionServer
3395 QuorumPeerMain
2932 SecondaryNameNode
3543 HMaster
2715 NameNode
root@master:~# hive
18/06/14 10:15:34 WARN conf.HiveConf: HiveConf of name hive.server2.http.endpoint does not exist
Logging initialized using configuration in jar:file:/usr/local/apache-hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.6.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/alluxio-1.7.0-hadoop-2.6/client/alluxio-1.7.0-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive>   show databases;
OK
default
hive
hivestudy
hrs
Time taken: 2.409 seconds, Fetched: 4 row(s)
hive> use default;
OK
Time taken: 0.058 seconds
hive> show tables;
OK
booktable
hbase_hive_......_operation
partition_test
peopledepljion
pokes
src
Time taken: 0.061 seconds, Fetched: 6 row(s)
hive> desc hbase_hive_......operation;
OK
rowkey                  string                  from deserializer   
info                    map      from deserializer   
Time taken: 0.624 seconds, Fetched: 2 row(s)
hive> 
hive> select * from hba........_operation;
OK
10200.......470188       {"opera....._time":"2017-12-20 13:22:17:17.0","oper.....me":"2017-12-30 15:22:17:17.0"}
Time taken: 1.304 seconds, Fetched: 1 row(s)
hive> 
HBase实战(3):使用HIVE SQL 操作分布式集群HBASE_第1张图片

你可能感兴趣的:(AI,&,Big,Data案例实战课程)