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

释放双眼,带上耳机,听听看~!

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

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


1
2
3
4
5
6
7
8
9
1hive>    
2    >
3    > CREATE EXTERNAL  TABLE hbase_hive_.....tion(rowkey string, info map<STRING,STRING>)  
4    > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
5    > WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:")  
6    > TBLPROPERTIES ("hbase.table.name" = "db_r......._operation");  
7OK
8Time taken: 0.959 seconds
9

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


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1root@master:~# jps
23808 Jps
33075 ResourceManager
43715 HRegionServer
53395 QuorumPeerMain
62932 SecondaryNameNode
73543 HMaster
82715 NameNode
9root@master:~# hive
1018/06/14 10:15:34 WARN conf.HiveConf: HiveConf of name hive.server2.http.endpoint does not exist
11Logging initialized using configuration in jar:file:/usr/local/apache-hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
12SLF4J: Class path contains multiple SLF4J bindings.
13SLF4J: 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]
14SLF4J: 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]
15SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
16SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
17

1
2
3
4
5
6
7
8
1hive>   show databases;
2OK
3default
4hive
5hivestudy
6hrs
7Time taken: 2.409 seconds, Fetched: 4 row(s)
8

1
2
3
4
1hive> use default;
2OK
3Time taken: 0.058 seconds
4

1
2
3
4
5
6
7
8
9
10
1hive> show tables;
2OK
3booktable
4hbase_hive_......_operation
5partition_test
6peopledepljion
7pokes
8src
9Time taken: 0.061 seconds, Fetched: 6 row(s)
10

1
2
3
4
5
6
7
1hive> desc hbase_hive_......operation;
2OK
3rowkey                  string                  from deserializer  
4info                    map<string,string>      from deserializer  
5Time taken: 0.624 seconds, Fetched: 2 row(s)
6hive>
7

1
2
3
4
5
6
1hive> select * from hba........_operation;
2OK
310200.......470188       {"opera....._time":"2017-12-20 13:22:17:17.0","oper.....me":"2017-12-30 15:22:17:17.0"}
4Time taken: 1.304 seconds, Fetched: 1 row(s)
5hive>
6

给TA打赏
共{{data.count}}人
人已打赏
安全运维

OpenSSH-8.7p1离线升级修复安全漏洞

2021-10-23 10:13:25

安全运维

设计模式的设计原则

2021-12-12 17:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索