Use Apache Phoenix with Linux-based HBase clusters in HDInsight

Learn how to use Apache Phoenix in Azure HDInsight, and how to use SQLLine. For more information about Phoenix, see Phoenix in 15 minutes or less. For the Phoenix grammar, see Phoenix grammar.

Note

For Phoenix version information about HDInsight, see What's new in the Hadoop cluster versions provided by HDInsight.

Use SQLLine

SQLLine is a command-line utility to execute SQL.

Prerequisites

Before you can use SQLLine, you must have the following items:

When you connect to an HBase cluster, you need to connect to one of the ZooKeeper VMs. Each HDInsight cluster has three ZooKeeper VMs.

To get the ZooKeeper host name

  1. Open Ambari by browsing to https://<cluster name>.azurehdinsight.net.
  2. To sign in, enter the HTTP (cluster) user name and password.
  3. In the left menu, select ZooKeeper. Three ZooKeeper Server instances are listed.
  4. Select one of the ZooKeeper Server instances. On the Summary pane, find the Hostname. It looks similar to zk1-jdolehb.3lnng4rcvp5uzokyktxs4a5dhd.bx.internal.cloudapp.net.

To use SQLLine

  1. Connect to the cluster by using SSH. For more information, see Use SSH with HDInsight.

  2. In SSH, use the following commands to run SQLLine:

     cd /usr/hdp/2.2.9.1-7/phoenix/bin
     ./sqlline.py <ZOOKEEPER SERVER FQDN>:2181:/hbase-unsecure
    
  3. To create an HBase table, and insert some data, run the following commands:

     CREATE TABLE Company (COMPANY_ID INTEGER PRIMARY KEY, NAME VARCHAR(225));
    
     !tables
    
     UPSERT INTO Company VALUES(1, 'Microsoft');
    
     SELECT * FROM Company;
    
     !quit
    

For more information, see the SQLLine manual and Phoenix grammar.

Next steps

In this article, you learned how to use Apache Phoenix in HDInsight. To learn more, see these articles: