Synchronizing HDFS ACLs and Sentry Permissions
The HDFS-Sentry plugin allows you to configure synchronization of Sentry privileges with HDFS ACLs for specific HDFS directories.
Continue reading:
Introduction
The integration of Sentry and HDFS permissions automatically keeps HDFS ACLs in sync with the privileges configured with Sentry. This feature offers the easiest way to share data between Hive, Impala and other components such as MapReduce, Spark, and Pig, while setting permissions for that data with just one set of rules through Sentry. It maintains the ability of Hive and Impala to set permissions on views, in addition to tables, while access to data outside of Hive and Impala (for example, reading files off HDFS) requires table permissions. HDFS permissions for some or all of the files that are part of tables defined in the Hive Metastore will now be controlled by Sentry.
- An HDFS NameNode plugin
- A Sentry-Hive Metastore plugin
- A Sentry Service plugin
With synchronization enabled, Sentry will translate permissions on databases and tables to the appropriate corresponding HDFS ACL on the underlying files in HDFS. For example, if a user group is assigned to a Sentry role that has SELECT permissions on a particular table, that user group will also have read access to the HDFS files that are part of that table. When you list those files in HDFS, this permission will be listed as an HDFS ACL. Or if a user group is assigned to a Sentry role that has SELECT permissions on a database, that user group will also have read access to the HDFS files that are part of that database. When you list those files in HDFS, those permissions will also be listed as an HDFS ACL.
Note that when Sentry was enabled, the hive user/group was given ownership of all files/directories in the Hive warehouse (/user/hive/warehouse). Hence, the resulting synchronized Sentry permissions will reflect this fact. If you skipped that step, Sentry permissions will be based on the existing Hive warehouse ACLs. Sentry will not automatically grant ownership to thehive user.
The mapping of Sentry privileges to HDFS ACLs is as follows:
- SELECT privilege -> Read access on the file.
- INSERT privilege -> Write access on the file.
- ALL privilege -> Read and Write access on the file.
- With synchronization enabled, your ability to set HDFS permissions for those files is disabled. Permissions for those particular files can be set only through Sentry, and when examined through HDFS these permissions appear as HDFS ACLs. A configurable set of users, such as hive and impala, will have full access to the files automatically. This ensures that a key requirement of using Sentry with Hive and Impala — giving these processes full access to regulate permissions on underlying data files — is met automatically.
-
Tables and databases that are not associated with Sentry, that is, have no user with Sentry privileges to access them, will retain their old ACLs.
-
Synchronized privileges are not persisted to HDFS. This means that when this feature is disabled, HDFS privileges will return to their original values.
- Setting HDFS ACLs on Sentry-managed paths will not affect the original HDFS ACLs. That is, if you set an ACL for a Hive object that also falls under the Sentry-managed path prefixes,
no action will be taken. If the path does not point to a Hive object managed by Sentry, HDFS ACLs will be set as expected.
Removing HDFC ACLs from paths will work the same way. If you attempt to remove an ACL associated with a Hive object managed by Sentry, no action will be taken. In all other cases, the ACL will be removed as is expected behavior.
-
With HDFS-Sentry sync enabled, if the NameNode plugin is unable to communicate with the Sentry Service for a particular period of time (configurable by the sentry.authorization-provider.cache-stale-threshold.ms property), permissions for all directories under Sentry-managed path prefixes, irrespective of whether those file paths correspond to Hive warehouse objects, will be set to the Hive System User and the Hive System Group.
- Column-level access control for access from Spark SQL is not supported by the HDFS-Sentry plug-in.
Prerequisites
- CDH 5.3.0 or higher
- (Strongly Recommended) Implement Kerberos authentication on your cluster.
- You must use the Sentry service, not policy file-based authorization.
- Enabling HDFS Extended Access Control Lists (ACLs) is required.
- There must be at least one Sentry service dependent on HDFS.
- The Sentry service must have at least one Sentry Server role.
- The Sentry service must have at least one dependent Hive service.
- The Hive service must have at least one Hive metastore role.
Enabling the HDFS-Sentry Plugin Using Cloudera Manager
- Go to the HDFS service.
- Click the Configuration tab.
- Select .
- Type Check HDFS Permissions in the Search box.
- Select Check HDFS Permissions.
- Select Enable Sentry Synchronization.
- Locate the Sentry Synchronization Path Prefixes property or search for it by typing its name in the Search box.
- Edit the Sentry Synchronization Path Prefixes property to list HDFS path prefixes where Sentry permissions should be enforced. Multiple HDFS path
prefixes can be specified. By default, this property points to /user/hive/warehouse and must always be non-empty. If you are using a non-default location for the Hive
warehouse, make sure you add it to the list of path prefixes. HDFS privilege synchronization will not occur for tables and databases located outside the HDFS regions listed here.
Important: Sentry will only manage paths that store Hive objects. If a path is listed under the Sentry Synchronization Path Prefixes, but there is no Hive object there, Sentry will not manage permissions for that path.
- Click Save Changes.
- Restart the cluster. Note that it may take an additional two minutes after cluster restart for privilege synchronization to take effect.
Enabling the HDFS-Sentry Plugin Using the Command Line
- This configuration process can be completed using either Cloudera Manager or the command-line instructions.
- This information applies specifically to CDH 5.15.0. If you use an earlier version of CDH, see the documentation for that version located at Cloudera Documentation.
To enable the Sentry plugins on an unmanaged cluster, you must explicitly allow the hdfs user to interact with Sentry, and install the plugin packages as described in the following sections.
Allowing the hdfs user to connect with Sentry
<property> <name>sentry.service.allow.connect</name> <value>impala,hive,hue,hdfs</value> </property>
Installing the HDFS-Sentry Plugin
Before using the instructions on this page to install the package, install the Cloudera yum, zypper/YaST or apt repository, and install or upgrade CDH 5 and make sure it is functioning correctly. For instructions, see Installing the Latest CDH 5 Release.
- The host running the NameNode and Secondary NameNode
- The host running the Hive Metastore
- The host running the Sentry Service
OS | Command |
---|---|
RHEL-compatible |
$ sudo yum install sentry-hdfs-plugin |
SLES |
$ sudo zypper install sentry-hdfs-plugin |
Ubuntu or Debian |
$ sudo apt-get install sentry-hdfs-plugin |
Configuring the HDFS NameNode Plugin
<property> <name>dfs.namenode.acls.enabled</name> <value>true</value> </property> <property> <name>dfs.namenode.authorization.provider.class</name> <value>org.apache.sentry.hdfs.SentryAuthorizationProvider</value> </property> <property> <name>dfs.permissions</name> <value>true</value> </property> <!-- Comma-separated list of HDFS path prefixes where Sentry permissions should be enforced. --> <!-- Privilege synchronization will occur only for tables located in HDFS regions specified here. --> <property> <name>sentry.authorization-provider.hdfs-path-prefixes</name> <value>/user/hive/warehouse</value> </property> <property> <name>sentry.hdfs.service.security.mode</name> <value>kerberos</value> </property> <property> <name>sentry.hdfs.service.server.principal</name> <value> SENTRY_SERVER_PRINCIPAL (for eg : sentry/_HOST@VPC.CLOUDERA.COM )</value> </property> <property> <name>sentry.hdfs.service.client.server.rpc-port</name> <value>SENTRY_SERVER_PORT</value> </property> <property> <name>sentry.hdfs.service.client.server.rpc-address</name> <value>SENTRY_SERVER_HOST</value> </property>
Configuring the Hive Metastore Plugin
<property> <name>sentry.metastore.plugins</name> <value>org.apache.sentry.hdfs.MetastorePlugin</value> </property> <property> <name>sentry.hdfs.service.client.server.rpc-port</name> <value> SENTRY_SERVER_PORT </value> </property> <property> <name>sentry.hdfs.service.client.server.rpc-address</name> <value> SENTRY_SERVER_HOSTNAME </value> </property> <property> <name>sentry.hdfs.service.client.server.rpc-connection-timeout</name> <value>200000</value> </property> <property> <name>sentry.hdfs.service.security.mode</name> <value>kerberos</value> </property> <property> <name>sentry.hdfs.service.server.principal</name> <value> SENTRY_SERVER_PRINCIPAL (for eg : sentry/_HOST@VPC.CLOUDERA.COM )</value> </property>
Configuring the Sentry Service Plugin
<property> <name>sentry.service.processor.factories</name> <value>org.apache.sentry.provider.db.service.thrift.SentryPolicyStoreProcessorFactory, org.apache.sentry.hdfs.SentryHDFSServiceProcessorFactory</value> </property> <property> <name>sentry.policy.store.plugins</name> <value>org.apache.sentry.hdfs.SentryPlugin</value> </property>
Testing the Sentry Synchronization Plugins
The following tasks will help you ensure that Sentry-HDFS synchronization has been enabled and configured correctly:
- (Recommended) Hue's Security application
- HiveServer2 CLI
- Impala CLI
- Access the tables and databases directly in HDFS. For example:
- List files inside the folder and verify that the file permissions shown in HDFS (including ACLs) match what was configured in Sentry.
- Run a MapReduce, Pig or Spark job that accesses those files. Pick any tool besides HiveServer2 and Impala
<< Managing the Sentry Service | ©2016 Cloudera, Inc. All rights reserved | Hive SQL Syntax for Use with Sentry >> |
Terms and Conditions Privacy Policy |