hive與hbase資料表關聯

2021-09-02 19:27:08 字數 1671 閱讀 5835

一、簡單介紹

hive的元資料儲存在metastore裡面,真實的資料一般位於hdfs中,可以通過hql來對資料進行分析。hbase中的資料也是存放在hdfs上的,可不可以使用hive來分析hbase中的資料呢?

二、hive表到hbase表的對映

2.1hbase表t1的結構和其中的資料如下圖

2.2建立hive表對映到hbase的表

首先輸入下面的命令進入hive的客戶端

hive --auxpath /usr/local/hive-0.14.0/lib/hive-hbase-handler-0.14.0.jar,/usr/local/hive-0.14.0/lib/zookeeper-3.4.5.jar -hiveconf hbase.master=hadoop26:60000 -hiveconf hbase.zookeeper.quorum=hadoop26

使用下面的語句建立hive表,資料是儲存在hbase中的

三、使用hql來查詢hbase中的資料

向hbase表t1中插入資料

put 't1','4','f1:name','zhaoliu'

再次從hive中查詢

hbase中的資料和hive是同步的,這也說明hive表的資料是位於hbase中的

四、使用hive向hbase中插入資料

4.1首先是需要建立乙個hive臨時表

create table h1_tmp 

(id int,name string,age int,gender string)

row format delimited

fields terminated by '\t';

4.2向臨時表中批量的上傳資料

4.3把臨時表h1_tmp的資料插入到目標表

insert into table h1 select * from h1_tmp; 

五、注意

如果hbase中新增新的列,那麼hive中是查詢不到的。

因為hive建立表的字段沒有hbase新列的對映。如下面的情況。

put 't1','4','f1:birthday','1993'

但是在hive中查不到

hive與hbase關聯表

關於 hbase 和 hive 關聯表 詳細介紹 hive 建立 關聯hbase表有2種形式 這種情況是hbase本來沒有這張表。hive建表時建立了hbase表.這種情況下,hdfs的hive表目錄有hive資料夾,但是裡面沒有資料 資料時存在hbase裡面的 hive insert overwr...

hive和hbase資料相互關聯

一 使用hive獲取,hbase中資料 1.create hadoop hbase hive human info 2.造數 put hadoop hbase hive human 1 info id 1 put hadoop hbase hive human 1 info name wang pu...

hive 表關聯hbase表 命令和總結

在hive shell中建立關聯表的命令如下 create table hive表名 rowkey date type,value1 date type,value2 date type,value3 date type stored by org.apache.hadoop.hive.hbase....