Hbase-hive Integration

Source: Internet
Author: User
Tags key string

First, Prepare the Environment

The prerequisites have been installed. HBase , Hive

Detection Hive/lib does the directory contain: hive-hbase-handler- version . Jar ( through this file and hbase communication )

Second, Copy Files

Enter the lib directory of hbase and copy the following file to:Lib of hive directory under

Hbase-client-0.98.0-hadoop2.jar

Hbase-common-0.98.0-hadoop2-tests.jar

Hbase-common-0.98.0-hadoop2.jar

Hbase-protocol-0.98.0-hadoop2.jar

Hbase-server-0.98.0-hadoop2.jar

Htrace-core-2.04.jar

Start Hive , the above integration completed

Third, assume that Hbase The following table already exists:

table name:testtable

column families:F

columns:IP

columns:URLs

You need to Create an external table in hive that points to hbase

The statements are as follows:

CREATE EXTERNAL TABLE log2 (key string, url String,ip string)

STORED by ' Org.apache.hadoop.hive.hbase.HBaseStorageHandler '

With Serdeproperties ("hbase.columns.mapping" = ": Key,f:url,f:ip")

Tblproperties ("hbase.table.name" = "log");

Four, Explanation:

Log2: represents Hive the name of the external table

Key : must have

When you createHive/hbasewhen the table is associated with theHBasetable structure will have a field by defaultKey, if there is not a field displayed' key 'so in the course of creating a table, you create it yourself, soHivethe corresponding table will cause problems, so theHivethe corresponding table must be addedKeyThis field, in order to avoid this problem, inHBaseadd that can be displayed in the table structure' key 'field, which is not prone to problems.

Hbase.columns.mapping Representations and HBase the columns do the mapping

Five, Validation

inserting data in hbase

Execute Queries in hive to query the data

Hbase-hive Integration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.