hive權限設置

1、打開權限控制,默認是沒有限制的
set hive.security.authorization.enabled=true; 
2、配置默認權限
hive.security.authorization.createtable.owner.grants = ALL  
hive.security.authorization.createtable.role.grants = admin_role:ALL  
hive.security.authorization.createtable.user.grants = user1,user2:select;user3:create  

在Cloudera Manager中配置
hive-site.xml 的 Hive 客戶端高級配置代碼段(安全閥)
hive-site.xml 的 HiveServer2 高級配置代碼段(安全閥)


hive.security.authorization.enabled
true


hive.security.authorization.createtable.owner.grants
ALL


hive.security.authorization.task.factory
org.apache.hadoop.hive.ql.parse.authorization.HiveAuthorizationTaskFactoryImpl

```
3、創建角色
CREATE ROLE test_role;
GRANT ROLE test_role TO USER mllib; 
如出現FAILED: SemanticException The current builtin authorization in Hive is incomplete and disabled.這個異常。
配置:set hive.security.authorization.task.factory = org.apache.hadoop.hive.ql.parse.authorization.HiveAuthorizationTaskFactoryImpl; 
分配權限-基於角色:
GRANT CREATE ON DATABASE default TO group test_role;  
GRANT SELECT on table authorization_test to group test_role;  
GRANT DROP on table authorization_test to group test_role;  
GRANT ALL on table authorization_test to group test_role; 
分配權限-基於用戶:
GRANT CREATE ON DATABASE default TO user mllib;  
GRANT SELECT on table authorization_test to user mllib;  
GRANT DROP on table authorization_test to user mllib;  
GRANT ALL on table authorization_test to user mllib; 

““
分配創建數據庫的權限
GRANT CREATE TO user root;

```
5、查看權限分配
SHOW GRANT user mllib ON DATABASE default;     
SHOW GRANT group test_role ON DATABASE default; 
6、刪除權限
revoke all on database spark from user mllib;
7、HIVE支持以下權限:
權限名稱 含義
ALL      :  所有權限
ALTER  :  允許修改元數據(modify metadata data of object)---表信息數據
UPDATE  :  允許修改物理數據(modify physical data of object)---實際數據
CREATE  :  允許進行Create操作
DROP  :  允許進行DROP操作
INDEX  :  允許建索引(目前還沒有實現)
LOCK  :  當出現併發的使用允許用戶進行LOCK和UNLOCK操作
SELECT  :  允許用戶進行SELECT操作
SHOW_DATABASE : 允許用戶查看可用的數據庫
8、登錄hive元數據庫,可以發現以下表:
Db_privs:記錄了User/Role在DB上的權限
Tbl_privs:記錄了User/Role在table上的權限
Tbl_col_privs:記錄了User/Role在table column上的權限
Roles:記錄了所有創建的role
Role_map:記錄了User與Role的對應關係
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章