【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

相关推荐
chde2Wang3 分钟前
hadoop部署错误-namenode address dfs.namenode.servicerpc-address not configured
java·大数据·hadoop
SelectDB技术团队18 小时前
Apache Doris 基于 Lance 的向量检索深度解析
数据库·数据仓库·数据分析·湖仓一体·apache doris·lakehouse·多模湖仓
泡干脆面就番茄20 小时前
Hive-DML:Load-Insert-Export-Import四种数据进出方式
大数据·数据仓库·hive·hadoop
SelectDB技术团队1 天前
日志场景 Elasticsearch 替换实操:建表、索引、写入链路与查询改写的完整参数
大数据·数据库·数据仓库·elasticsearch·全文检索·日志分析·apache doris
省钱兄--zs2 天前
深圳24小时自助健身房软硬件解决方案实战指南与开发流程详解
java·数据仓库·spring boot·小程序·架构
省钱兄--zs2 天前
无人自助拼豆系统架构设计与功能实现落地部署全流程实战指南
java·数据仓库·spring boot·系统架构·需求分析
棣廷2 天前
初识Hive(1)
数据仓库·hive·hadoop
Francek Chen2 天前
【大数据处理与分析】数据仓库Hive:07 Hive HA基本原理
大数据·数据仓库·hive·hadoop·数据分析
棣廷2 天前
初识Hadoop
大数据·hadoop·分布式
这个DBA有点耶2 天前
ELT工具选型:ETL与ELT差异、CDC同步机制与主流工具对比`
数据库·数据仓库·sql·database·dba·etl·数据库管理员