Skip to content

Commit 53dade8

Browse files
authored
Merge pull request #97325 from dagiro/freshness74
freshness74
2 parents cdae7e4 + 6ac8719 commit 53dade8

File tree

2 files changed

+68
-47
lines changed

2 files changed

+68
-47
lines changed

articles/hdinsight/domain-joined/apache-domain-joined-run-hive.md

Lines changed: 68 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
---
22
title: Apache Hive policies in Apache Ranger - Azure HDInsight
33
description: Learn how to configure Apache Ranger policies for Hive in an Azure HDInsight service with Enterprise Security Package.
4-
ms.service: hdinsight
54
author: omidm1
65
ms.author: omidm
76
ms.reviewer: jasonh
8-
ms.custom: hdinsightactive
7+
ms.service: hdinsight
98
ms.topic: conceptual
10-
ms.date: 09/24/2018
9+
ms.custom: hdinsightactive
10+
ms.date: 11/27/2019
1111
---
1212

1313
# Configure Apache Hive policies in HDInsight with Enterprise Security Package
14-
Learn how to configure Apache Ranger policies for Apache Hive. In this article, you create two Ranger policies to restrict access to the hivesampletable. The hivesampletable comes with HDInsight clusters. After you have configured the policies, you use Excel and ODBC driver to connect to Hive tables in HDInsight.
14+
15+
Learn how to configure Apache Ranger policies for Apache Hive. In this article, you create two Ranger policies to restrict access to the hivesampletable. The hivesampletable comes with HDInsight clusters. After you've configured the policies, you use Excel and ODBC driver to connect to Hive tables in HDInsight.
1516

1617
## Prerequisites
18+
1719
* A HDInsight cluster with Enterprise Security Package. See [Configure HDInsight clusters with ESP](apache-domain-joined-configure.md).
1820
* A workstation with Office 2016, Office 2013 Professional Plus, Office 365 Pro Plus, Excel 2013 Standalone, or Office 2010 Professional Plus.
1921

2022
## Connect to Apache Ranger Admin UI
2123
**To connect to Ranger Admin UI**
2224

23-
1. From a browser, connect to Ranger Admin UI. The URL is https://<ClusterName>.azurehdinsight.net/Ranger/.
25+
1. From a browser, navigate to the Ranger Admin UI at `https://CLUSTERNAME.azurehdinsight.net/Ranger/` where CLUSTERNAME is the name of your cluster.
2426

2527
> [!NOTE]
2628
> Ranger uses different credentials than Apache Hadoop cluster. To prevent browsers using cached Hadoop credentials, use new InPrivate browser window to connect to the Ranger Admin UI.
@@ -32,87 +34,105 @@ Learn how to configure Apache Ranger policies for Apache Hive. In this article,
3234
Currently, Ranger only works with Yarn and Hive.
3335

3436
## Create Domain users
37+
3538
See [Create a HDInsight cluster with ESP](apache-domain-joined-configure-using-azure-adds.md#create-a-hdinsight-cluster-with-esp), for information on how to create hiveruser1 and hiveuser2. You use the two user accounts in this article.
3639

3740
## Create Ranger policies
38-
In this section, you create two Ranger policies for accessing hivesampletable. You give select permission on different set of columns. Both users were created using [Create a HDInsight cluster with ESP](apache-domain-joined-configure-using-azure-adds.md#create-a-hdinsight-cluster-with-esp). In the next section, you will test the two policies in Excel.
41+
42+
In this section, you create two Ranger policies for accessing hivesampletable. You give select permission on different set of columns. Both users were created using [Create a HDInsight cluster with ESP](apache-domain-joined-configure-using-azure-adds.md#create-a-hdinsight-cluster-with-esp). In the next section, you'll test the two policies in Excel.
3943

4044
**To create Ranger policies**
4145

4246
1. Open Ranger Admin UI. See Connect to Apache Ranger Admin UI.
43-
2. Click **<ClusterName>_hive**, under **Hive**. You shall see two pre-configure policies.
44-
3. Click **Add New Policy**, and then enter the following values:
45-
46-
* Policy name: read-hivesampletable-all
47-
* Hive Database: default
48-
* table: hivesampletable
49-
* Hive column: *
50-
* Select User: hiveuser1
51-
* Permissions: select
52-
53-
![HDInsight ESP Ranger Hive policy configure](./media/apache-domain-joined-run-hive/hdinsight-domain-joined-configure-ranger-policy.png).
54-
55-
> [!NOTE]
56-
> If a domain user is not populated in Select User, wait a few moments for Ranger to sync with AAD.
57-
>
58-
>
59-
4. Click **Add** to save the policy.
47+
2. Select **CLUSTERNAME_Hive**, under **Hive**. You shall see two pre-configure policies.
48+
3. Select **Add New Policy**, and then enter the following values:
49+
50+
|Property |Value |
51+
|---|---|
52+
|Policy Name|read-hivesampletable-all|
53+
|Hive Database|default|
54+
|table|hivesampletable|
55+
|Hive Column|*|
56+
|Select User|hiveuser1|
57+
|Permissions|select|
58+
59+
![HDInsight ESP Ranger Hive policies configure](./media/apache-domain-joined-run-hive/hdinsight-domain-joined-configure-ranger-policy.png).
60+
61+
> [!NOTE]
62+
> If a domain user is not populated in Select User, wait a few moments for Ranger to sync with AAD.
63+
64+
4. Select **Add** to save the policy.
65+
6066
5. Repeat the last two steps to create another policy with the following properties:
6167

62-
* Policy name: read-hivesampletable-devicemake
63-
* Hive Database: default
64-
* table: hivesampletable
65-
* Hive column: clientid, devicemake
66-
* Select User: hiveuser2
67-
* Permissions: select
68+
|Property |Value |
69+
|---|---|
70+
|Policy Name|read-hivesampletable-devicemake|
71+
|Hive Database|default|
72+
|table|hivesampletable|
73+
|Hive column|clientid, devicemake|
74+
|Select User|hiveuser2|
75+
|Permissions|select|
6876

6977
## Create Hive ODBC data source
78+
7079
The instructions can be found in [Create Hive ODBC data source](../hadoop/apache-hadoop-connect-excel-hive-odbc-driver.md).
7180

7281
| Property |Description |
7382
| --- | --- |
7483
| Data Source Name | Give a name to your data source |
75-
| Host | Enter <HDInsightClusterName>.azurehdinsight.net. For example, myHDICluster.azurehdinsight.net |
84+
| Host | Enter CLUSTERNAME.azurehdinsight.net. For example, myHDICluster.azurehdinsight.net |
7685
| Port | Use **443**. (This port has been changed from 563 to 443.) |
7786
| Database | Use **Default**. |
7887
| Hive Server Type | Select **Hive Server 2** |
7988
| Mechanism | Select **Azure HDInsight Service** |
8089
| HTTP Path | Leave it blank. |
81-
| User Name | Enter [email protected]. Update the domain name if it is different. |
90+
| User Name | Enter [email protected]. Update the domain name if it's different. |
8291
| Password | Enter the password for hiveuser1. |
8392

8493
Make sure to click **Test** before saving the data source.
8594

8695
## Import data into Excel from HDInsight
87-
In the last section, you have configured two policies. hiveuser1 has the select permission on all the columns, and hiveuser2 has the select permission on two columns. In this section, you impersonate the two users to import data into Excel.
96+
97+
In the last section, you've configured two policies. hiveuser1 has the select permission on all the columns, and hiveuser2 has the select permission on two columns. In this section, you impersonate the two users to import data into Excel.
8898

8999
1. Open a new or existing workbook in Excel.
90-
2. From the **Data** tab, click **From Other Data Sources**, and then click **From Data Connection Wizard** to launch the **Data Connection Wizard**.
91100

92-
![Open data connection wizard][img-hdi-simbahiveodbc.excel.dataconnection]
93-
3. Select **ODBC DSN** as the data source, and then click **Next**.
94-
4. From ODBC data sources, select the data source name that you created in the previous step, and then click **Next**.
95-
5. Reenter the password for the cluster in the wizard, and then click **OK**. Wait for the **Select Database and Table** dialog to open. This can take a few seconds.
96-
6. Select **hivesampletable**, and then click **Next**.
97-
7. Click **Finish**.
98-
8. In the **Import Data** dialog, you can change or specify the query. To do so, click **Properties**. This can take a few seconds.
99-
9. Click the **Definition** tab. The command text is:
101+
1. From the **Data** tab, navigate to **Get Data** > **From Other Sources** > **From ODBC** to launch the **From ODBC** window.
102+
103+
![Open data connection wizard](./media/apache-domain-joined-run-hive/simbahiveodbc-excel-dataconnection1.png)
104+
105+
1. From the drop-down list, select the data source name that you created in the last section and then select **OK**.
106+
107+
1. For the first use, an **ODBC driver** dialog will open. Select **Windows** from the left menu. Then select **Connect** to open the **Navigator** window.
108+
109+
1. Wait for the **Select Database and Table** dialog to open. This can take a few seconds.
110+
111+
1. Select **hivesampletable**, and then select **Next**.
112+
113+
1. Select **Finish**.
114+
115+
1. In the **Import Data** dialog, you can change or specify the query. To do so, select **Properties**. This can take a few seconds.
116+
117+
1. Select the **Definition** tab. The command text is:
100118

101119
SELECT * FROM "HIVE"."default"."hivesampletable"
102120

103-
By the Ranger policies you defined, hiveuser1 has select permission on all the columns. So this query works with hiveuser1's credentials, but this query does not work with hiveuser2's credentials.
121+
By the Ranger policies you defined, hiveuser1 has select permission on all the columns. So this query works with hiveuser1's credentials, but this query doesn't work with hiveuser2's credentials.
104122

105-
![Connection Properties][img-hdi-simbahiveodbc-excel-connectionproperties]
106-
10. Click **OK** to close the Connection Properties dialog.
107-
11. Click **OK** to close the **Import Data** dialog.
108-
12. Reenter the password for hiveuser1, and then click **OK**. It takes a few seconds before data gets imported to Excel. When it is done, you shall see 11 columns of data.
123+
1. Select **OK** to close the Connection Properties dialog.
124+
125+
1. Select **OK** to close the **Import Data** dialog.
126+
127+
1. Reenter the password for hiveuser1, and then click **OK**. It takes a few seconds before data gets imported to Excel. When it's done, you shall see 11 columns of data.
109128

110129
To test the second policy (read-hivesampletable-devicemake), you created in the last section
111130

112131
1. Add a new sheet in Excel.
113132
2. Follow the last procedure to import the data. The only change you make is to use hiveuser2's credentials instead of hiveuser1's. This fails because hiveuser2 only has permission to see two columns. You shall get the following error:
114133

115134
[Microsoft][HiveODBC] (35) Error from Hive: error code: '40000' error message: 'Error while compiling statement: FAILED: HiveAccessControlException Permission denied: user [hiveuser2] does not have [SELECT] privilege on [default/hivesampletable/clientid,country ...]'.
135+
116136
3. Follow the same procedure to import data. This time, use hiveuser2's credentials, and also modify the select statement from:
117137

118138
SELECT * FROM "HIVE"."default"."hivesampletable"
@@ -121,9 +141,10 @@ To test the second policy (read-hivesampletable-devicemake), you created in the
121141

122142
SELECT clientid, devicemake FROM "HIVE"."default"."hivesampletable"
123143

124-
When it is done, you shall see two columns of data imported.
144+
When it's done, you shall see two columns of data imported.
125145

126146
## Next steps
147+
127148
* For configuring a HDInsight cluster with Enterprise Security Package, see [Configure HDInsight clusters with ESP](apache-domain-joined-configure.md).
128149
* For managing a HDInsight cluster with ESP, see [Manage HDInsight clusters with ESP](apache-domain-joined-manage.md).
129150
* For running Hive queries using SSH on HDInsight clusters with ESP, see [Use SSH with HDInsight](../hdinsight-hadoop-linux-use-ssh-unix.md#domainjoined).
132 KB
Loading

0 commit comments

Comments
 (0)