一.任務(wù)描述
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創(chuàng)建udf函數(shù)時(shí)報(bào)沒有admin的權(quán)限。
相關(guān)配置:
設(shè)置成false則,yarn作業(yè)獲取到的hiveserver2用戶都為hive用戶。
設(shè)置成true則為實(shí)際的用戶名
<property>
<name>hive.server2.enable.doAs</name>
<value>false</value>
</property>
<property>
<name>hive.users.in.admin.role</name>
<value>taiyi</value>
</property>
看到設(shè)置了hive.users.in.admin.role=taiyi,但執(zhí)行時(shí)卻報(bào)沒有admin權(quán)限。。。那admin權(quán)限如何正確的設(shè)置和使用呢?
?
二. 解決
hive官網(wǎng)描述了關(guān)于SQL Standard Based Hive Authorization,即hive對執(zhí)行sql時(shí)的鑒權(quán)。
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對標(biāo)準(zhǔn)sql鑒權(quán)提供了新的鑒權(quán)選擇。且這種方式不會(huì)出現(xiàn)向后兼容的問題。當(dāng)用戶設(shè)置了此安全模型,默認(rèn)的鑒權(quán)將會(huì)被棄用。
看下官網(wǎng)如何配置的admin權(quán)限
For Hive 0.14 and Newer
這里我們只關(guān)注前兩項(xiàng),其中第二項(xiàng):hive.users.in.admin.role
描述了,此值生效之后,屬于admin角色的用戶在獲得admin角色的權(quán)限之前需要執(zhí)行“set role”命令,因?yàn)槟J(rèn)情況下該角色不在當(dāng)前角色中。
?
這里大概知道了是因?yàn)闆]有執(zhí)行:set role admin;
導(dǎo)致admin角色用戶沒有生效。
進(jìn)入hive終端之后,執(zhí)行set role admin;
,再執(zhí)行udf的創(chuàng)建:
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';
?
官網(wǎng)的Troubleshooting也描述了此問題文章來源:http://www.zghlxwxcb.cn/news/detail-775130.html
至此解決;
https://cwiki.apache.org/confluence/display/Hive/SQL+Standard+Based+Hive+Authorization文章來源地址http://www.zghlxwxcb.cn/news/detail-775130.html
到了這里,關(guān)于【hive-解決】HiveAccessControlException Permission denied: CREATEFUNCTION的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!