Use Apache Phoenix with Linux-based Apache HBase clusters in HDInsight
Learn how to use Apache Phoenix in Azure HDInsight, and how to use SQLLine. For more information about Phoenix, see Apache Phoenix in 15 minutes or less. For the Phoenix grammar, see Apache Phoenix grammar.
For Phoenix version information about HDInsight, see What's new in the Apache Hadoop cluster versions provided by HDInsight.
SQLLine is a command-line utility to execute SQL.
Before you can use SQLLine, you must have the following items:
- An Apache HBase cluster in HDInsight. To create one, see Get started with Apache HBase in HDInsight.
When you connect to an HBase cluster, you need to connect to one of the Apache ZooKeeper VMs. Each HDInsight cluster has three ZooKeeper VMs.
To get the ZooKeeper host name
- Open Apache Ambari by browsing to https://<cluster name>.azurehdinsight.net.
- To sign in, enter the HTTP (cluster) user name and password.
- In the left menu, select ZooKeeper. Three ZooKeeper Server instances are listed.
- 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
Connect to the cluster by using SSH. For more information, see Use SSH with HDInsight.
In SSH, use the following commands to run SQLLine:
cd /usr/hdp/188.8.131.52-7/phoenix/bin ./sqlline.py <ZOOKEEPER SERVER FQDN>:2181:/hbase-unsecure
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
In this article, you learned how to use Apache Phoenix in HDInsight. To learn more, see these articles:
- HDInsight HBase overview. Apache HBase is an Apache, open-source, NoSQL database built on Apache Hadoop that provides random access and strong consistency for large amounts of unstructured and semistructured data.
- Provision Apache HBase clusters on Azure Virtual Network. With virtual network integration, Apache HBase clusters can be deployed to the same virtual network as your applications, so applications can communicate directly with HBase.
- Configure Apache HBase replication in HDInsight. Learn how to set up Apache HBase replication across two Azure datacenters.