91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

通過Hive查詢 HBase

發布時間:2020-07-24 09:50:23 來源:網絡 閱讀:1047 作者:MIKE老畢 欄目:關系型數據庫

線上的zipkin的存儲是利用的HBase0.94.6,一開始Dev想直接寫MR來做離線分析,后來聊了下發現走Hive會提高開發的效率(當然,這里查詢HBaseSQL接口還有phoenixImpala等,只不過都還不夠成熟,并且是離線分析不是adhocquery,BTW,前階段和intel的聊過他們的Hive Over HBase是跳過MR的,效率非常贊,不過錢也略貴了=.=);

其實用Hive查詢HBase非常簡單:

//首先在HBase里建一張表并插入幾條數據
hbase(main):003:0> create 'table_inhbase','cf'
0 row(s) in 1.2060 seconds
=> Hbase::Table - table_inhbase
hbase(main):004:0> list
TABLE                                                               
table_inhbase                                                        
1 row(s) in 0.0350 seconds
hbase(main):005:0> put 'table_inhbase','row1','cf:a','value1'
0 row(s) in 0.0830 seconds
hbase(main):006:0> put 'table_inhbase','row2','cf:a','value2'
0 row(s) in 0.0200 seconds
hbase(main):007:0> put 'table_inhbase','row3','cf:b','value3'
0 row(s) in 0.0180 seconds
hbase(main):008:0> scan 'table_inhbase'
ROW                                        COLUMN+CELL              
 row1                                      column=cf:a, timestamp=1383736436773,value=value1                                                             
 row2                                      column=cf:a, timestamp=1383736462917,value=value2                                                             
 row3                                      column=cf:b, timestamp=1383736476017,value=value3                                                            
3 row(s) in 0.0660 seconds
//在Hive里創建一個外部表,注意要在hive-site.xml加入ZK,否則會hang住,一直去重試localhost:2181
CREATE EXTERNAL TABLE ext_table_inhbase(key string, avalue string,bvaluestring) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES ("hbase.columns.mapping" ="cf:a,cf:b") 
TBLPROPERTIES("hbase.table.name" = "table_inhbase");
hive> CREATE EXTERNAL TABLE ext_table_inhbase(key string, avaluestring,bvalue string) 
    > STORED BY'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
    > WITH SERDEPROPERTIES("hbase.columns.mapping" = "cf:a,cf:b") 
    > TBLPROPERTIES("hbase.table.name" ="table_inhbase");
OK
//注意,這里要加入這2個jar包:hbase-0.94.6-cdh5.4.0.jar,hive-hbase-handler-0.10.0-cdh5.4.0.jar否則會拋出異常
hive> select * from ext_table_inhbase;
OK
row1    value1  NULL
row2    value2  NULL
row3    NULL    value3
Time taken: 0.609 seconds
hive> select key,avalue from ext_table_inhbase;
java.io.IOException: Cannot create an instance of InputSplit.apache.hadoop.hive.hbase.HBaseSplit:Classorg.apache.hadoop.hive.hbase.HBaseSplit not found
        at org.apache.hadoop.hive.ql.io.HiveInputFormat$HiveInputSplit.readFields(HiveInputFormat.java:146)
        atorg.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:73)
        atorg.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:44)
        atorg.apache.hadoop.mapred.MapTask.getSplitDetails(MapTask.java:356)
        atorg.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:388)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:332)
        atorg.apache.hadoop.mapred.Child$4.run(Child.java:268)
        atjava.security.AccessController.doPrivileged(Native Method)
        atjavax.security.auth.Subject.doAs(Subject.java:396)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1408)
hive> select key,avalue from ext_table_inhbase;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Hadoop job information for Stage-1: number of mappers: 1; number ofreducers: 0
19:33:55,386 Stage-1 map = 0%,  reduce = 0%
19:34:01,472 Stage-1 map = 100%,  reduce = 0%, CumulativeCPU 2.73 sec
19:34:02,495 Stage-1 map = 100%,  reduce = 0%, CumulativeCPU 2.73 sec
19:34:03,512 Stage-1 map = 100%,  reduce = 100%,Cumulative CPU 2.73 sec
MapReduce Total cumulative CPU time: 2 seconds 730 msec
Ended Job = job_201311061424_0003
MapReduce Jobs Launched:
Job 0: Map: 1   Cumulative CPU: 2.73 sec   HDFS Read:255 HDFS Write: 39 SUCCESS
Total MapReduce CPU Time Spent: 2 seconds 730 msec
OK
row1    value1
row2    value2
//嘗試通過HiveServer去查詢
beeline> !connect jdbc:hive2://test-2:10000 hdfs hdfsorg.apache.hive.jdbc.HiveDriver        
Connecting to jdbc:hive2://test-2:10000
Connected to: Hive (version 0.10.0)
Driver: Hive (version 0.10.0-cdh5.4.0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://test-2:10000> show databases;
+----------------+
| database_name  |
+----------------+
| default        |
+----------------+
1 row selected (1.483 seconds)
0: jdbc:hive2://test-2:10000> show tables;
+--------------------+
|      tab_name      |
+--------------------+
| ext_table_inhbase  |
|test              |
+--------------------+
2 rows selected (0.657 seconds)
0: jdbc:hive2://test-2:10000> select count(*) from ext_table_inhbase;
+------+
| _c0  |
+------+
| 3    |
+------+


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

游戏| 陇南市| 呼和浩特市| 柞水县| 泸溪县| 射洪县| 石狮市| 霍林郭勒市| 容城县| 恩施市| 共和县| 阿尔山市| 深泽县| 建阳市| 汕头市| 方山县| 正宁县| 大洼县| 敦化市| 马关县| 武定县| 屏山县| 玛沁县| 台安县| 青田县| 盐山县| 八宿县| 大邑县| 尉氏县| 台前县| 宝坻区| 扶风县| 顺昌县| 富蕴县| 潜山县| 天津市| 永寿县| 文化| 丰都县| 新竹县| 大石桥市|