This topic describes how to connect to and use LindormTable.

Prerequisites

Usage notes

  • You can connect to Lindorm instances only by using VPCs.
    Important To connect to a Lindorm instance over the Internet or the Lindorm instance that you want to access is a single-node Lindorm instance, you must upgrade your SDK and change the configurations before you perform the operations described in this topic. For more information, see Step 1 in Use the ApsaraDB for HBase API for Java to connect to and use LindormTable.
  • If your application is deployed on an Elastic Compute Service (ECS) instance, make sure that your Lindorm instance and the ECS instance meet the following requirements in advance to ensure network connectivity.
    • Your Lindorm instance and ECS instance are deployed in the same region. We recommend that you deploy the two instances in the same zone to reduce network latency.
    • Your Lindorm instance and ECS instance are deployed in the same VPC.

Configure connection parameters in Hive

Method 1: Add connection configurations to the hive-site.xml file.

<configuration>
    <property>
        <name>hbase.zookeeper.quorum</name>
      <!--
   The LindormTable endpoint of the HBase API for Java
    -->
        <value>ld-bp1461s38p7y9****-proxy-lindorm.lindorm.rds.aliyuncs.com:30020</value>
    </property>
 </configuration>

Method 2: Run a command in the Hive client.

// Specify the LindormTable endpoint of the HBase API for Java.
set hbase.zookeeper.quorum=ld-bp1461s38p7y9****-proxy-lindorm.lindorm.rds.aliyuncs.com:30020

Procedure

  1. Configure the LindormTable endpoint of the Lindorm instance to which you want to connect in the Hive client.
    hive
    // Specify the LindormTable endpoint of the HBase API for Java.
    set hbase.zookeeper.quorum=ld-bp1461s38p7y9****-proxy-lindorm.lindorm.rds.aliyuncs.com:30020
  2. Create a table named hive_hbase_table in the Lindorm instance.
    CREATE 'hive_hbase_table','cf1'
  3. Create an external table in Hive.
    CREATE EXTERNAL TABLE hive_hbase_table(key int, value string)
    STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
    TBLPROPERTIES ("hbase.table.name" = "hive_hbase_table", "hbase.mapred.output.outputtable" = "hive_hbase_table");

    If OK is contained in the returned information, the external table is created.

  4. Insert data to the external table and check whether the data is inserted.
    • Insert data in the external table in Hive and check whether the data is inserted in Lindorm.

      Insert data to the external table:

      insert into hive_hbase_table values(212,'bab');
      In Lindorm, check whether the data is inserted to the external table:
      scan 'hive_hbase_table'
      The following result is returned:
      ROW                   COLUMN+CELL
      212                   column=cf1:val, timestamp=2023-03-13T15:35:10.270, value=bab                      
    • Insert data to the hive_hbase_table table in Lindorm and check whether the data is inserted in Hive.
      Insert data to the hive_hbase_table table:
      put 'hive_hbase_table','213','cf1:val','dadsadasda'
      In Hive, check whether the data is inserted to the hive_hbase_table table:
      SELECT * FROM hive_hbase_table;
      The following result is returned:
      212   bab
      213   dadsadasda
Important You cannot use Hive to directly read files in Lindorm. However, you can create or associate a Hive external table to read data from or write data to Lindorm.