hive与hbase集成
環(huán)境:
hadoop2.7.7
hive3.1.0
hbase2.0.2
1.jar包拷貝(之所以用這種方式,是因為這種方式最為穩(wěn)妥,最開始用的軟連接的方式,總是卻少jar包)到hive的lib目錄下刪除所有hbase相關(guān)的jar
rm -rf hbase-*.jar
接著從hbase的lib目錄下拷貝所有的hbase相關(guān)jar
cp -a? hbasehome/lib/hbase-*.jar ./
zookeeper相關(guān)的jar也要進(jìn)行替換
2.在hive的hive-site.xml中添加zk的相關(guān)配置
1 <property> 2 <name>hive.zookeeper.quorum</name> 3 <value>hadoop002,hadoop003,hadoop004</value> 4 <description>The list of ZooKeeper servers to talk to. This is only needed for read/write locks.</description> 5 </property> 6 <property> 7 <name>hive.zookeeper.client.port</name> 8 <value>2181</value> 9 <description>The port of ZooKeeper servers to talk to. This is only needed for read/write locks.</description> 10 </property>3.在hive中創(chuàng)建表,執(zhí)行完建表語句后,會在hbase生成對應(yīng)的hbase_emp_table表,但是這種表是non-native table類型的表,無法被truncate,也無法使用load加載數(shù)據(jù)
1 CREATE TABLE hive_hbase_emp_table( 2 empno int, 3 ename string, 4 job string, 5 mgr int, 6 hiredate string, 7 sal double, 8 comm double, 9 deptno int) 10 STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 11 WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno") 12 TBLPROPERTIES ("hbase.table.name" = "hbase_emp_table");4.插入數(shù)據(jù)
上面說了無法通過load加載數(shù)據(jù),所以借助臨時表進(jìn)行insert,已提前創(chuàng)建了emp表.并插入了數(shù)據(jù)
empno對應(yīng)hbase_emp_table的行鍵,不能為null
insert into table hive_hbase_emp_table select * from emp where empno is not null;
5.之后分別在hive和hbase查詢數(shù)據(jù)即可
6.無法創(chuàng)建新的管理表與hbase_emp_table關(guān)聯(lián),只能通過創(chuàng)建外部表的方式與hbase_emp_table進(jìn)行關(guān)聯(lián)
轉(zhuǎn)載于:https://www.cnblogs.com/tele-share/p/9984903.html
總結(jié)
以上是生活随笔為你收集整理的hive与hbase集成的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Axure实现多用户注册验证
- 下一篇: Maximum Xor Secondar