hive记录-cdh配置hive和sentry

Posted xinfang520

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive记录-cdh配置hive和sentry相关的知识,希望对你有一定的参考价值。

1.cdh添加组件-sentry-选择主机-配置数据库

2.配置数据库

1)mysql -uroot -p

2) create database sentry DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

3) grant all privileges on sentry.* to [email protected]‘%‘ identified by ‘123‘ with grant option;

选择mysql数据库主机、用户名、密码、需要将mysql jdbc驱动拷贝到对应主机下的cm/share/cmf/lib和/opt/cloudera/parcels/CDH-5.10.2-1.cdh5.10.2.p0.5/lib/sentry/lib

测试连接-下一步-创建数据库表,开启sentry服务

3.hive配置下勾选sentry和hue配置勾选sentry

4.重启hive和hue

5.beeline登录进行授权角色

beeline -u "jdbc:hive2://hadoop03:10000/" -n hive -p hive -d org.apache.hive.jdbc.HiveDriver

1)创建角色并授权给组

执行下面的 sql 语句创建 role、group等:
create role admin_role;
GRANT ALL ON SERVER server1 TO ROLE admin_role;
GRANT ROLE admin_role TO GROUP admin;
GRANT ROLE admin_role TO GROUP hive;

create role test_role;
GRANT ALL ON DATABASE filtered TO ROLE test_role;
GRANT ROLE test_role TO GROUP test;
上面创建了两个角色:

admin_role,具有管理员权限,可以读写所有数据库,并授权给 admin 和 hive 组(对应操作系统上的组)
test_role,只能读写 filtered 数据库,并授权给 test 组。
因为系统上没有test用户和组,所以需要手动创建:
groupadd test
useradd test

测试admin_role角色
使用hive用户访问beeline:
$ beeline -u "jdbc:hive2://hadoop03:10000/" -n hive -p hive -d org.apache.hive.jdbc.HiveDriver
set system:user.name;
show roles;
SHOW GRANT ROLE test_role;
SHOW GRANT ROLE admin_role;


测试test_role角色
使用test用户访问beeline:
$ beeline -u "jdbc:hive2://hadoop03:10000/" -n test -p test -d org.apache.hive.jdbc.HiveDriver
set system:user.name;






















以上是关于hive记录-cdh配置hive和sentry的主要内容,如果未能解决你的问题,请参考以下文章

hive启用sentry

0031-如何在CDH启用Kerberos的情况下安装及使用Sentry

CDH大数据平台 17Cloudera Manager Console之Sentry权限hive测试(markdown新版)

如何使用Sentry管理Hive外部表(补充)

如何查看集成Sentry后Hive作业的真实用户

0035-如何使用Sentry管理Hive外部表(补充)