Hive與Hbase整合 1.文檔 Hive HBase Integration ...
Hive與Hbase整合
1.文檔
2.拷貝jar文件
2.1.把Hbase的lib目錄下麵的jar文件全部拷貝到Hive的lib目錄下麵
cd /home/hbase/lib cp ./* /home/hive/lib
2.2.把Hive的lib目錄下麵的hive-hbase-handler-0.13.1.jar拷貝到Hbase的lib目錄下麵
cp /home/hive/lib/hive-hbase-handler-0.13.1.jar /home/hbase/lib/
3.修改Hive/conf目錄下麵的配置文件
cd /home/hive/conf vi hive-site.xml <!-- Hbase zookeeper quorum --> <property> <name>hbase.zookeeper.quorum</name> <value>node1,node2,node3</value> </property>
4.在Hbase中創建表
--在Hbase中創建表 create 'hbase_to_hive_t_user', 'cf_user_info' hbase(main):010:0> desc 'hbase_to_hive_t_user' Table hbase_to_hive_t_user is ENABLED COLUMN FAMILIES DESCRIPTION {NAME => 'cf_user_info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_S COPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => ' true'} 1 row(s) in 0.0650 seconds
5.在Hbase表中插入數據
--插入數據 put 'hbase_to_hive_t_user', '1', 'cf_user_info:name','Tom' put 'hbase_to_hive_t_user', '1', 'cf_user_info:age',24 put 'hbase_to_hive_t_user', '2', 'cf_user_info:name','John' put 'hbase_to_hive_t_user', '2', 'cf_user_info:age',18 put 'hbase_to_hive_t_user', '3', 'cf_user_info:name','Steven' put 'hbase_to_hive_t_user', '3', 'cf_user_info:age',38 scan 'hbase_to_hive_t_user' hbase(main):009:0> scan 'hbase_to_hive_t_user' ROW COLUMN+CELL 1 column=cf_user_info:age, timestamp=1546754368046, value=24 1 column=cf_user_info:name, timestamp=1546754367972, value=Tom 2 column=cf_user_info:age, timestamp=1546754368166, value=18 2 column=cf_user_info:name, timestamp=1546754368103, value=John 3 column=cf_user_info:age, timestamp=1546754370447, value=38 3 column=cf_user_info:name, timestamp=1546754368211, value=Steven 3 row(s) in 0.1600 seconds
6.在Hive中創建資料庫表關聯Hbase裡面的表
--如果你想要Hive去訪問Hbase中已經存在的表,你可以創建外部表(CREATE EXTERNAL TABLE) CREATE EXTERNAL TABLE hive_access_hbase_table_t_user (key string, name string, age int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf_user_info:name,cf_user_info:age") TBLPROPERTIES ("hbase.table.name" = "hbase_to_hive_t_user");
6.1.在Hive中查詢Hbase表裡的數據
select * from hive_access_hbase_table_t_user; hive> select * from hive_access_hbase_table_t_user; OK 1 Tom 24 2 John 18 3 Steven 38 Time taken: 0.325 seconds, Fetched: 3 row(s)
7.Reference
https://blog.csdn.net/qq_33689414/article/details/80328665
https://blog.csdn.net/aaronhadoop/article/details/28398157
========================================================
More reading,and english is important.
I'm Hongten
大哥哥大姐姐,覺得有用打賞點哦!你的支持是我最大的動力。謝謝。
Hongten博客排名在100名以內。粉絲過千。
Hongten出品,必是精品。
E | [email protected] B | http://www.cnblogs.com/hongten
========================================================