Sentry管理Hive目录acl -setacl不生效
CDH在启动Sentry后/user/hive/warehouse这个目录 hdfs手动setacl会不生效
首先确保hdfs参数dfs.namenode.acls.enabled=true;还有另一个acl
![0F296062-C217-4461-8429-9795FE70DB72.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325541505808.png)
hive这边确认参数:
![6BB7E656-1646-4531-A4F4-092377EBF986.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325536648352.png)
ps: 报错:FAILED: InvalidConfigurationExceptionhive.server2.authentication can’t be none in non-testing mode
Hive服务—>配置---->范围—>Hive(服务范围)—>类别—>主要---->高级–>sentry-site.xml的hive服务高级配置代码段,如图:[sentry.hive.testing.mode]
![664A6CDA-8146-4CD5-9CCE-5DDF45099C0B.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325554825417.png)
首先我们先找一个目录测试下
hdfs dfs -getfacl /mgtest
![B1556D87-8872-4AAD-B6DB-BBA697381773.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325560636214.png)
[hdfs@cdh01 ~]$ hdfs dfs -setfacl -R -m group:hive:rwx /mgtest
[hdfs@cdh01 ~]$ hdfs dfs -getfacl /mgtest
![6D50CCE0-B27B-46C4-B035-2C7BF90D2E49.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325566500593.png)
接下来我们测试
测试目录:/user/hive/warehouse/mgtest.db
hdfs dfs -setfacl -R -m group:mgtest02:rwx /user/hive/warehouse/mgtest.db
hdfs dfs -getfacl /user/hive/warehouse/mgtest.db
![2EA3B95B-7AF3-4017-BA9D-18FBDC33A79A.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325573455837.png)
可以看出来 我们set的并没有生效。
解决方法:
进入beeline中
首先我们创建一个
CREATE ROLE mgtest01;
授予其对mgtest01库的管理权限
grant all on database mgtest to role mgtest01 with grant option;
查看mgtest01角色的权限列表
show grant role mgtest01;
![image.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325587816905.png)
GRANT ROLE mgtest01 TO GROUP mgtest03;
![06418B8C-D562-4A99-AFBD-C698D69F0DB4.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325595450175.png)
查看hdfs权限
hdfs dfs -getfacl /user/hive/warehouse/mgtest.db
![D035A47F-4054-4799-838C-449307BA576B.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325602233166.png)
再来一次试试
GRANT ROLE mgtest01 TO GROUP mgtest04;
查看权限
hdfs dfs -getfacl /user/hive/warehouse/mgtest.db
![F1C3CDFD-2A86-4240-BDC6-3BA321B8CFA3.png](https://yunche.pro/blog/zb_users/upload/2023/11/202311301701325611453462.png)
ps:
查看所有角色:show roles;
查看当前角色:show current roles;
查看当前用户:select current_user();
Ps: admin授权操作
CREATE ROLE admin;
grant all on server server1 to role admin;
GRANT ROLE admin TO GROUP hive;