这篇文章是关于将 Sentry 与 Hive 绑定(bind)的。我已经面对这个问题有一段时间了。
我的主要目标是提供对在创建角色时被赋予特权的数据库和表的访问。
所以首先,我在 Cloudera Manager 中启用了 Sentry 并重新启动了服务器
然后我创建了角色并在直线中给予特权,如下所示 -
CREATE ROLE role1;
GRANT ROLE role1 TO GROUP hive;
GRANT SELECT ON DATABASE db1 TO ROLE role1;
GRANT ALL ON URI 'file:///path/to/hive-udfs.jar' TO ROLE role1;
SET ROLE role1;
SHOW CURRENT ROLES;
现在,如果我在
beeline
中执行以下命令, 我只看到 DEFAULT
数据库和 DB1
数据库很好SHOW DATABASES;
当我通过创建
SentryHiveMetaStoreClient
的对象使用代码执行相同操作时,就会出现问题。并访问其方法,例如- getAllDatabases()
或 getAllTables("table_name")
.在这里我得到错误:Caused by: java.lang.NullPointerException
at org.apache.sentry.binding.metastore.SentryHiveMetaStoreClient.getConf(SentryHiveMetaStoreClient.java:161)
at org.apache.sentry.binding.metastore.SentryHiveMetaStoreClient.getHiveAuthzBinding(SentryHiveMetaStoreClient.java:135)
at org.apache.sentry.binding.metastore.SentryHiveMetaStoreClient.filterDatabases(SentryHiveMetaStoreClient.java:98)
at org.apache.sentry.binding.metastore.SentryHiveMetaStoreClient.getAllDatabases(SentryHiveMetaStoreClient.java:65)
at my.data.in.hive.resources.MetadataResource.getDatabase(MetadataResource.java:46)
我面临的另一个问题是,当我创建
HiveMetaStoreClient
的对象时并访问其方法,如 getAllDatabases()
它向我展示了所有数据库都放弃了各种角色赋予的特权概念,这很好。但是如果我访问它的方法 - listRoleNames()
,我得到管理员和公众。这不应该给出我在 beeline
中创建的角色的名称吗?即role1
?在 Cloudera Manager 中配置 Sentry 和 Hive 可能存在一些问题,或者我可能做错了什么。关于可以做些什么来使它发挥作用的任何想法?
最佳答案
关于你的问题
May be there is some problem in configuring Sentry and Hive ...
和给定的错误信息
Caused by: java.lang.NullPointerException
at org.apache.sentry.binding.metastore.SentryHiveMetaStoreClient ...
您可以检查绑定(bind)是否正确配置。起点可以是Configure Sentry to show/hide different databases for different users .
关于apache - 无法将 Sentry 与 Hive 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46339661/