User hdfs does not have privileges for CREATEDATABASE

4.Sentry测试

4.1创建hive超级用户


1.使用beeline连接HiveServer2,并登录hive用户

[[email protected] ~]# beeline 
Beeline version 1.1.0-cdh5.12.0 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: hive
Enter password for jdbc:hive2://localhost:10000: 
Connected to: Apache Hive (version 1.1.0-cdh5.12.0)
Driver: Hive JDBC (version 1.1.0-cdh5.12.0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000> 

User hdfs does not have privileges for CREATEDATABASE

注意:标红部分为输入的hive用户,输入的hive用户并未真正的校验

2.创建一个admin角色

0: jdbc:hive2://localhost:10000> create role admin;
...
INFO  : OK
No rows affected (2.52 seconds)
0: jdbc:hive2://localhost:10000> 

User hdfs does not have privileges for CREATEDATABASE

3.为admin角色赋予超级权限

0: jdbc:hive2://localhost:10000> grant all on server server1 to role admin;

...

INFO : OK

No rows affected (0.221 seconds)

0: jdbc:hive2://localhost:10000>

User hdfs does not have privileges for CREATEDATABASE

4.将admin角色授权给hive用户组

0: jdbc:hive2://localhost:10000> grant role admin to group hive;

...

INFO : OK

No rows affected (0.162 seconds)

0: jdbc:hive2://localhost:10000>

User hdfs does not have privileges for CREATEDATABASE

4.2创建test表


使用beeline登录hive用户,创建一个test表,并插入测试数据

0: jdbc:hive2://localhost:10000> create table test (s1 string, s2 string) row format delimitedfields terminated by ',';

...

INFO : OK

No rows affected (0.592 seconds)

0: jdbc:hive2://localhost:10000> insert into test values('a','b'),('1','2');

...

INFO : OK

No rows affected (20.123 seconds)

0: jdbc:hive2://localhost:10000>

User hdfs does not have privileges for CREATEDATABASE

参考:https://cloud.tencent.com/developer/article/1077868