The HBase SQL service provides SQL support for HBase 2.x based on Apache Phoenix 5.x. You can use a Phoenix thin client to connect to ApsaraDB for HBase. The SQL service is integrated with Server Load Balancer (SLB). Round robin distribution is used to evenly distribute requests among query servers. The Phoenix thin client supports multiple programming languages, such as Python and Go.

Procedure

  1. Activate the HBase SQL service.

    After you create an HBase instance, log on to the ApsaraDB for HBase console. In the left-side navigation pane, click SQL Service. Then, click Enable Now to activate the HBase SQL service.

    When you activate the HBase SQL service, the HBase instance needs to be restarted and some memory resources are occupied. It takes approximately 10 minutes for the service to activate. The amount of time required to activate the service depends on the number of nodes. We recommend that you activate the service during off-peak hours.

  2. Manage the HBase SQL service.
    After the HBase SQL service is activated, you can manage the HBase SQL service on the HBase SQL page. For example, you can update the minor version of the HBase SQL service, restart the HBase SQL service, and enable public access to the HBase SQL service.
    Note The HBase SQL service supports SLB connections and single node connections. These connections are used in different scenarios.
    • SLB connections: The HBase SQL service uses SLB to evenly distribute highly concurrent read and write requests among QueryServers. This improves the throughput of the cluster.
    • Single node connections: Single node connections are ideal for the scenarios in which you perform time-consuming operations, such as creating indexes on large tables, executing the UPSERT...SELECT statement to import data, and running complex queries. In these scenarios, SLB connections may time out due to a long response time for requests.
  3. Prepare a client.
    Create an Elastic Compute Service (ECS) instance that is in the same network as your ApsaraDB for HBase cluster. We recommend that you create an ECS instance that is in the same virtual private cloud (VPC) as your ApsaraDB for HBase cluster.
    1. Run the following command to view the private IP address of the ECS instance:
      hostname -i
    2. Add the returned private IP address of the ECS instance to the whitelist of the ApsaraDB for HBase cluster. For more information, see Configure a whitelist.
  4. Use a client to connect to the HBase SQL service.
    1. Download the latest version of the HBase SQL client on the created ECS instance.
      wget https://hbase-opt.oss-cn-hangzhou.aliyuncs.com/ali-phoenix-5.2.4.1-HBase-2.x.tar.gz
    2. Decompress the client package.
      tar zxvf ali-phoenix-5.2.4.1-HBase-2.x.tar.gz
    3. Start the thin client tool.
      bin/sqlline-thin.py http://xxx-proxy-phoenix.hbase.rds.aliyuncs.com:8765
  5. Run the following command to check whether the configuration is successful:
    !tables
    If a list of tables is returned, the configuration is successful. You can then get started with the HBase SQL service.
    Note It takes a while to create the meta table after the first connection is established.
  6. Run the following command to exit Phoenix:
    !quit

Comparison