[关闭]
@awsekfozc 2016-01-23T06:57:08.000000Z 字数 1937 阅读 1616

Hbase集成Hive

Hbase

设置依赖包

  1. export HBASE_HOME=/opt/moduels/hbase-0.98.6-hadoop2
  2. export HIVE_HOME=/opt/moduels/hive-0.13.1/lib
  3. ln -s $HBASE_HOME/lib/hbase-server-0.98.6-hadoop2.jar $HIVE_HOME/hbase-server-0.98.6-hadoop2.jar
  4. ln -s $HBASE_HOME/lib/hbase-client-0.98.6-hadoop2.jar $HIVE_HOME/hbase-client-0.98.6-hadoop2.jar
  5. ln -s $HBASE_HOME/lib/hbase-protocol-0.98.6-hadoop2.jar $HIVE_HOME/hbase-protocol-0.98.6-hadoop2.jar
  6. ln -s $HBASE_HOME/lib/hbase-it-0.98.6-hadoop2.jar $HIVE_HOME/hbase-it-0.98.6-hadoop2.jar
  7. ln -s $HBASE_HOME/lib/htrace-core-2.04.jar $HIVE_HOME/htrace-core-2.04.jar
  8. ln -s $HBASE_HOME/lib/hbase-hadoop2-compat-0.98.6-hadoop2.jar $HIVE_HOME/hbase-hadoop2-compat-0.98.6-hadoop2.jar
  9. ln -s $HBASE_HOME/lib/hbase-hadoop-compat-0.98.6-hadoop2.jar $HIVE_HOME/hbase-hadoop-compat-0.98.6-hadoop2.jar
  10. ln -s $HBASE_HOME/lib/high-scale-lib-1.1.1.jar $HIVE_HOME/high-scale-lib-1.1.1.jar
  11. ln -s $HBASE_HOME/lib/hbase-common-0.98.6-hadoop2.jar $HIVE_HOME/hbase-common-0.98.6-hadoop2.jar

配置

  1. #hive-site.xml
  2. <!--hbase zookeeper-->
  3. <property>
  4. <name>hbase.zookeeper.quorum</name>
  5. <value>hadoop.zc.com</value>
  6. </property>

示例

  1. CREATE TABLE default.hbase_table_1(
  2. id int,
  3. name string
  4. )
  5. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  6. WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name")
  7. TBLPROPERTIES ("hbase.table.name" = "xyz");
  8. INSERT OVERWRITE TABLE default.hbase_table_1
  9. SELECT id, name FROM db_hive.student;
  10. ##-----------------------------------------------------------------------------
  11. CREATE EXTERNAL TABLE hbase_table_2(
  12. uuid int,
  13. username string
  14. )
  15. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  16. WITH SERDEPROPERTIES ("hbase.columns.mapping" = "info:name")
  17. TBLPROPERTIES("hbase.table.name" = "xyz");
  18. ##-----------------------------------------------------------------------------
  19. CREATE EXTERNAL TABLE hbase_table_3(
  20. uuid int,
  21. username string
  22. )
  23. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  24. WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name")
  25. TBLPROPERTIES("hbase.table.name" = "xyz");

在此输入正文

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注