Skip to content

Commit 06af8a9

Browse files
authored
Merge pull request #76250 from dagiro/quickStarts3
quickStarts3
2 parents 052d27c + 06799a9 commit 06af8a9

File tree

2 files changed

+100
-46
lines changed

2 files changed

+100
-46
lines changed

articles/hdinsight/hbase/TOC.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
maintainContext: true
1313
- name: Quickstarts
1414
items:
15+
- name: Query Apache HBase - Apache Phoenix
16+
href: apache-hbase-phoenix-squirrel-linux.md
1517
- name: Query Apache HBase - HBase Shell
1618
href: ./query-hbase-with-hbase-shell.md
1719
- name: Get started
@@ -52,8 +54,6 @@
5254
- name: Apache Phoenix in HDInsight
5355
href: ../hdinsight-phoenix-in-hdinsight.md
5456
maintainContext: true
55-
- name: Use Apache Phoenix and SQLLine
56-
href: apache-hbase-phoenix-squirrel-linux.md
5757
- name: Use the Apache Phoenix Query Server REST SDK
5858
href: apache-hbase-using-phoenix-query-server-rest-sdk.md
5959
- name: Analyze big data
Lines changed: 98 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,131 @@
11
---
2-
title: Use Apache Phoenix and SQLLine with HBase in Azure HDInsight
2+
title: 'Quickstart: Query Apache HBase in Azure HDInsight - Apache Phoenix'
33
description: Learn how to use Apache Phoenix in HDInsight. Also, learn how to install and set up SQLLine on your computer to connect to an HBase cluster in HDInsight.
44
author: hrasheed-msft
55
ms.reviewer: jasonh
66

77
ms.service: hdinsight
88
ms.custom: hdinsightactive
9-
ms.topic: conceptual
10-
ms.date: 01/03/2018
9+
ms.topic: quickstart
10+
ms.date: 05/08/2019
1111
ms.author: hrasheed
12-
1312
---
14-
# Use Apache Phoenix with Linux-based Apache HBase clusters in HDInsight
15-
Learn how to use [Apache Phoenix](https://phoenix.apache.org/) in Azure HDInsight, and how to use SQLLine. For more information about Phoenix, see [Apache Phoenix in 15 minutes or less](https://phoenix.apache.org/Phoenix-in-15-minutes-or-less.html). For the Phoenix grammar, see [Apache Phoenix grammar](https://phoenix.apache.org/language/index.html).
1613

17-
> [!NOTE]
18-
> For Phoenix version information about HDInsight, see [What's new in the Apache Hadoop cluster versions provided by HDInsight](../hdinsight-component-versioning.md).
19-
>
20-
>
14+
# Quickstart: Query Apache HBase in Azure HDInsight with Apache Phoenix
2115

22-
## Use SQLLine
23-
[SQLLine](http://sqlline.sourceforge.net/) is a command-line utility to execute SQL.
16+
In this quickstart, you learn how to use the Apache Phoenix to run HBase queries in Azure HDInsight. Apache Phoenix is a SQL query engine for Apache HBase. It is accessed as a JDBC driver, and it enables querying and managing HBase tables by using SQL. [SQLLine](http://sqlline.sourceforge.net/) is a command-line utility to execute SQL.
2417

25-
### Prerequisites
26-
Before you can use SQLLine, you must have the following items:
18+
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2719

28-
* **An Apache HBase cluster in HDInsight**. To create one, see [Get started with Apache HBase in HDInsight](./apache-hbase-tutorial-get-started-linux.md).
20+
## Prerequisites
2921

30-
When you connect to an HBase cluster, you need to connect to one of the [Apache ZooKeeper](https://zookeeper.apache.org/) VMs. Each HDInsight cluster has three ZooKeeper VMs.
22+
* An Apache HBase cluster. See [Create cluster](../hadoop/apache-hadoop-linux-tutorial-get-started.md#create-cluster) to create an HDInsight cluster. Ensure you choose the **HBase** cluster type.
3123

32-
**To get the ZooKeeper host name**
24+
* An SSH client. For more information, see [Connect to HDInsight (Apache Hadoop) using SSH](../hdinsight-hadoop-linux-use-ssh-unix.md).
3325

34-
1. Open [Apache Ambari](https://ambari.apache.org/) by browsing to **https://\<cluster name\>.azurehdinsight.net**.
35-
2. To sign in, enter the HTTP (cluster) user name and password.
36-
3. In the left menu, select **ZooKeeper**. Three **ZooKeeper Server** instances are listed.
37-
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*.
26+
## Identify a ZooKeeper node
3827

39-
**To use SQLLine**
28+
When you connect to an HBase cluster, you need to connect to one of the Apache ZooKeeper nodes. Each HDInsight cluster has three ZooKeeper nodes. Curl can be used to quickly identify a ZooKeeper node. Edit the curl command below by replacing `PASSWORD` and `CLUSTERNAME` with the relevant values, and then enter the command in a command prompt:
4029

41-
1. Connect to the cluster by using SSH. For more information, see [Use SSH with HDInsight](../hdinsight-hadoop-linux-use-ssh-unix.md).
30+
```cmd
31+
curl -u admin:PASSWORD -sS -G https://CLUSTERNAME.azurehdinsight.net/api/v1/clusters/CLUSTERNAME/services/ZOOKEEPER/components/ZOOKEEPER_SERVER
32+
```
4233

43-
2. In SSH, use the following commands to run SQLLine:
34+
A portion of the output will look similar to:
4435

45-
cd /usr/hdp/current/phoenix-client/bin
46-
./sqlline.py <ZOOKEEPER SERVER FQDN>:2181:/hbase-unsecure
47-
3. To create an HBase table, and insert some data, run the following commands:
36+
```output
37+
{
38+
"href" : "http://hn1-brim.432dc3rlshou3ocf251eycoapa.bx.internal.cloudapp.net:8080/api/v1/clusters/myCluster/hosts/zk0-brim.432dc3rlshou3ocf251eycoapa.bx.internal.cloudapp.net/host_components/ZOOKEEPER_SERVER",
39+
"HostRoles" : {
40+
"cluster_name" : "myCluster",
41+
"component_name" : "ZOOKEEPER_SERVER",
42+
"host_name" : "zk0-brim.432dc3rlshou3ocf251eycoapa.bx.internal.cloudapp.net"
43+
}
44+
```
4845

49-
CREATE TABLE Company (COMPANY_ID INTEGER PRIMARY KEY, NAME VARCHAR(225));
46+
Take note of the value for `host_name` for later use.
5047

51-
!tables
48+
## Create a table and manipulate data
5249

53-
UPSERT INTO Company VALUES(1, 'Microsoft');
50+
You can use SSH to connect to HBase clusters, and then use Apache Phoenix to create HBase tables, insert data, and query data.
5451

55-
SELECT * FROM Company;
52+
1. Use `ssh` command to connect to your HBase cluster. Edit the command below by replacing `CLUSTERNAME` with the name of your cluster, and then enter the command:
5653

57-
!quit
54+
```cmd
55+
56+
```
5857
59-
For more information, see the [SQLLine manual](http://sqlline.sourceforge.net/#manual) and [Apache Phoenix grammar](https://phoenix.apache.org/language/index.html).
58+
2. Change directory to the Phoenix client. Enter the following command:
6059
61-
## Next steps
62-
In this article, you learned how to use Apache Phoenix in HDInsight. To learn more, see these articles:
60+
```bash
61+
cd /usr/hdp/current/phoenix-client/bin
62+
```
63+
64+
3. Launch [SQLLine](http://sqlline.sourceforge.net/). Edit the command below by replacing `ZOOKEEPER` with the ZooKeeper node identified earlier, then enter the command:
65+
66+
```bash
67+
./sqlline.py ZOOKEEPER:2181:/hbase-unsecure
68+
```
69+
70+
4. Create an HBase table. Enter the following command:
71+
72+
```sql
73+
CREATE TABLE Company (company_id INTEGER PRIMARY KEY, name VARCHAR(225));
74+
```
75+
76+
5. Use the SQLLine `!tables` command to list all tables in HBase. Enter the following command:
77+
78+
```sqlline
79+
!tables
80+
```
81+
82+
6. Insert values in the table. Enter the following command:
83+
84+
```sql
85+
UPSERT INTO Company VALUES(1, 'Microsoft');
86+
UPSERT INTO Company VALUES(2, 'Apache');
87+
```
88+
89+
7. Query the table. Enter the following command:
6390
64-
* [HDInsight HBase overview][hdinsight-hbase-overview].
65-
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.
66-
* [Provision Apache HBase clusters on Azure Virtual Network][hdinsight-hbase-provision-vnet].
67-
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.
68-
* [Configure Apache HBase replication in HDInsight](apache-hbase-replication.md). Learn how to set up Apache HBase replication across two Azure datacenters.
91+
```sql
92+
SELECT * FROM Company;
93+
```
6994
95+
8. Delete a record. Enter the following command:
96+
97+
```sql
98+
DELETE FROM Company WHERE COMPANY_ID=1;
99+
```
100+
101+
9. Drop the table. Enter the following command:
102+
103+
```hbase
104+
DROP TABLE Company;
105+
```
106+
107+
10. Use the SQLLine `!quit` command to exit SQLLine. Enter the following command:
108+
109+
```sqlline
110+
!quit
111+
```
112+
113+
## Clean up resources
114+
115+
After you complete the quickstart, you may want to delete the cluster. With HDInsight, your data is stored in Azure Storage, so you can safely delete a cluster when it is not in use. You are also charged for an HDInsight cluster, even when it is not in use. Since the charges for the cluster are many times more than the charges for storage, it makes economic sense to delete clusters when they are not in use.
116+
117+
To delete a cluster, see [Delete an HDInsight cluster using your browser, PowerShell, or the Azure CLI](../hdinsight-delete-cluster.md).
118+
119+
## Next steps
70120
71-
[azure-portal]: https://portal.azure.com
72-
[vnet-point-to-site-connectivity]: https://msdn.microsoft.com/library/azure/09926218-92ab-4f43-aa99-83ab4d355555#BKMK_VNETPT
121+
In this quickstart, you learned how to use the Apache Phoenix to run HBase queries in Azure HDInsight. To learn more about Apache Phoenix, the next article will provide a deeper examination.
73122
74-
[hdinsight-hbase-provision-vnet]:apache-hbase-provision-vnet.md
75-
[hdinsight-hbase-overview]:apache-hbase-overview.md
123+
> [!div class="nextstepaction"]
124+
> [Apache Phoenix in HDInsight](../hdinsight-phoenix-in-hdinsight.md)
76125
126+
## See Also
77127
128+
* [SQLLine manual](http://sqlline.sourceforge.net/#manual).
129+
* [Apache Phoenix grammar](https://phoenix.apache.org/language/index.html).
130+
* [Apache Phoenix in 15 minutes or less](https://phoenix.apache.org/Phoenix-in-15-minutes-or-less.html)
131+
* [HDInsight HBase overview](./apache-hbase-overview.md)

0 commit comments

Comments
 (0)