一、前置条件
操作系统:CentOS 7.4 minimal
CM版本: 6.2.1
CDH版本:6.2.1
MySQL版本: 5.5.65-MariaDB
JDK: 1.8.0_151
浏览器版本: Chrome
内存:32G以上
CPU :8core
网络:千兆以上
集群未启用Kerberos
CDH6.2.1集群运行正常
Kudu已安装并集成impala
Sentry已安装并正确配置
二、测试kudu1.9.0的sentry授权
1、创建admin管理角色
创建admin管理员role,并赋予所有权限,将集群节点impala用户加入hive用户组
create role admin_role;
grant all on server server1 to role admin_role;
grant role admin_role to group hive;
2、创建一张kudu表
CEATE TABLE my_first_table
( id BIGINT,
name STRING,
PRIMARY KEY(id))
PARTITION BY HASH PARTITIONS 16
STORED AS KUDU;
3、插入数据
INSERT INTO my_first_table VALUES (1, "lily"), (2, "tom"), (3, "jerry"), (4, "catty");
select * from my_first_table;
4、未授权用户查询
使用root用户连接impala-shell
show tables;
5、授权用户查询权限
1) 创建read_role
使用impala用户连接impala-shell
create role read_role;
grant role read_role to group root;
grant select on table my_first_table to role read_role;
2) 使用root用户进行查询数据
使用root用户连接impala-shell
show tables;
select * from my_first_table;
查询数据成功
3) 使用root用户进行插入数据
使用root用户连接impala-shell
INSERT INTO my_first_table VALUES (5, "jack");
插入数据失败
6、授权用户插入权限
1) 创建insert_role
使用impala用户连接impala-shell
create role insert_role;
grant role insert_role to group root;
grant insert on table my_first_table to role insert_role;
取消root 用户组select权限
revoke select on table my_first_table from role read_role;
2) 使用root用户进行插入数据
使用root用户连接impala-shell
INSERT INTO my_first_table VALUES (5, "jack");
插入数据成功
3) 使用root用户进行查询数据
使用root用户连接impala-shell
select * from my_first_table;
因为取消了root用户组查询权限,故查询失败