hive中User: xxx is not allowed to impersonate xxx

本文介绍了解决Hive插入数据时报权限错误的方法。通过调整hive-site.xml中的hive.server2.enable.doAs配置项,可以避免因用户权限问题导致的任务失败。

今天使用hive,插入数据是使用insert,遇到报错

INFO  : Launching Job 1 out of 3
INFO  : Starting task [Stage-1:MAPRED] in serial mode
INFO  : Number of reduce tasks determined at compile time: 1
INFO  : In order to change the average load for a reducer (in bytes):
INFO  :   set hive.exec.reducers.bytes.per.reducer=<number>
INFO  : In order to limit the maximum number of reducers:
INFO  :   set hive.exec.reducers.max=<number>
INFO  : In order to set a constant number of reducers:
INFO  :   set mapreduce.job.reduces=<number>
ERROR : Job Submission failed with exception 'org.apache.hadoop.security.authorize.AuthorizationException(User: bigdata is not allowed to impersonate bigdata)'
org.apache.hadoop.security.authorize.AuthorizationException: User: bigdata is not allowed to impersonate bigdata

ERROR : FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask. User: bigdata is not allowed to impersonate bigdata
INFO  : Completed executing command(queryId=bigdata_20220114234734_7f82943d-3d16-4314-9224-c958dac724a8); Time taken: 852.104 seconds

后面发现是hive-site.xml文件出现问题,没有添加
hive.server2.enable.doAs配置
在hive目录下的conf文件下的hive-site.xml文件,添加配置

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

然后就可以正常操作了

hive.server2.enable.doAs设置成false则,yarn作业获取到的hiveserver2用户都为hive用户。

设置成true则为实际的用户名

当出现 `[08S01] Could not open client transport with JDBC Uri: jdbc:hive2://192.168.1.191:10000: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: root is not allowed to impersonate root` 错误,通常是由于 Hadoop 的代理用户配置问题导致的。以下是一些可能的解决方法: ### 配置 Hadoop 的代理用户 需要在 `core-site.xml` 文件中配置允许代理的用户和主机。在 NameNode 所在节点的 `core-site.xml` 中添加以下配置: ```xml <property> <name>hadoop.proxyuser.root.hosts</name> <value>*</value> </property> <property> <name>hadoop.proxyuser.root.groups</name> <value>*</value> </property> ``` 上述配置中,`hadoop.proxyuser.root.hosts` 设置为 `*` 表示允许从任何主机进行代理,`hadoop.proxyuser.root.groups` 设置为 `*` 表示允许代理任何用户组。如果需要更严格的安全控制,可以将 `*` 替换为具体的主机名或用户组名。 ### 重启 Hadoop 服务 在修改 `core-site.xml` 文件后,需要重启 Hadoop 相关服务,使配置生效。可以使用以下命令重启 HDFS 和 YARN: ```bash $ stop-dfs.sh $ start-dfs.sh $ stop-yarn.sh $ start-yarn.sh ``` ### 检查 HiveServer2 配置 确保 HiveServer2 配置正确,并且使用的用户具有足够的权限。可以检查 HiveServer2 的启动用户和配置文件。 ### 检查网络连接 确保 JDBC 连接的主机和端口正确,并且网络连接正常。可以使用 `ping` 和 `telnet` 命令来测试网络连接: ```bash $ ping 192.168.1.191 $ telnet 192.168.1.191 10000 ``` ### 检查防火墙设置 确保防火墙没有阻止 JDBC 连接的端口(通常是 10000)。可以临时关闭防火墙进行测试: ```bash $ systemctl stop firewalld ``` 如果关闭防火墙后可以正常连接,需要配置防火墙规则允许该端口的流量通过。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值