【hive-解决】HiveAccessControlException Permission denied: CREATEFUNCTION

文章目录

一.任务描述

cpp 复制代码
 Error while compiling statement: FAILED:  HiveAccessControlException Permission denied: Principal [name=root, type=USER] does not have following privileges for operation 
 CREATEFUNCTION [ADMIN PRIVILEGE on INPUT, ADMIN PRIVILEGE on 
 OUTPUT]

问题表象:使用root用户通过hive创建udf函数时报没有admin的权限。

相关配置:

xml 复制代码
设置成false则,yarn作业获取到的hiveserver2用户都为hive用户。
设置成true则为实际的用户名

  <property>
     <name>hive.server2.enable.doAs</name>
     <value>false</value>
  </property>

  <property>
	<name>hive.users.in.admin.role</name>               
	<value>taiyi</value>
  </property>

看到设置了hive.users.in.admin.role=taiyi,但执行时却报没有admin权限。。。那admin权限如何正确的设置和使用呢?

二. 解决

hive官网描述了关于SQL Standard Based Hive Authorization,即hive对执行sql时的鉴权。

https://cwiki.apache.org/confluence/display/Hive/SQL+Standard+Based+Hive+Authorization#SQLStandardBasedHiveAuthorization-Troubleshooting

The SQL standards based authorization option (introduced in Hive 0.13) provides a third option for authorization in Hive. This is recommended because it allows Hive to be fully SQL compliant in its authorization model without causing backward compatibility issues for current users. As users migrate to this more secure model, the current default authorization could be deprecated.

hive对标准sql鉴权提供了新的鉴权选择。且这种方式不会出现向后兼容的问题。当用户设置了此安全模型,默认的鉴权将会被弃用。

看下官网如何配置的admin权限

For Hive 0.14 and Newer

这里我们只关注前两项,其中第二项:hive.users.in.admin.role 描述了,此值生效之后,属于admin角色的用户在获得admin角色的权限之前需要执行"set role"命令,因为默认情况下该角色不在当前角色中。

这里大概知道了是因为没有执行:set role admin; 导致admin角色用户没有生效。

进入hive终端之后,执行set role admin; ,再执行udf的创建:

shell 复制代码
set role admin;

create temporary function ip_get as 'xxx.xxx.IpRegionUdf'
using
jar 'hdfs://namenode:9000/home/user/etl-hive-functions-1.0.jar';

官网的Troubleshooting也描述了此问题

至此解决;

https://cwiki.apache.org/confluence/display/Hive/SQL+Standard+Based+Hive+Authorization

相关推荐
nvd112 天前
折腾 Niri WM:手搓一个完美的多显示器下拉终端 (Drop-down Terminal)
数据仓库
QQ12958455042 天前
FERP50 - Excel以存储过程方式访问数据仓库
数据仓库·spark·excel
It's Q2 天前
Hive序列函数&&排名函数
数据仓库·hive·hadoop
Irene19912 天前
外部表(EXTERNAL_TABLE)Hive 借用数据,删表不删数据
hive·内部表·外部表
WL_Aurora3 天前
Hadoop HA高可用架构深度解析
大数据·hadoop·架构
Irene19913 天前
Windows 11 WSL Ubuntu 环境:实际安装 Hive 踩坑实录
hive·windows·ubuntu
Irene19913 天前
Windows 11 WSL Ubuntu 环境:实际安装 Hadoop 踩坑实录
linux·hadoop·ubuntu
Irene19913 天前
(课堂笔记)Hive 分区、分桶与数据倾斜
hive·hadoop
Irene19914 天前
在 WSL Ubuntu 上安装和使用 Hive
linux·hive·ubuntu
二宝哥4 天前
大数据之安装Hadoop3.1.4
大数据·hadoop