User: root is not allowed to impersonate root (state=08S01,code=0)

时间:2021-07-14
本文章向大家介绍User: root is not allowed to impersonate root (state=08S01,code=0),主要包括User: root is not allowed to impersonate root (state=08S01,code=0)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

问题描述:

hadoop集群和hive安装成功以后,在hive安装目录下使用bin/hive命令进入hive界面,在里面增删改查都没有问题,但是

使用bin/hiveserver2启动hiveserver2服务,然后使用beeline(bin/beeline -u jdbc:hive2://hdp01:10000 -n xx -p xxx)连接hiveserver2报错:

Error: Could not open client transport with JDBC Uri: jdbc:hive2://hdp01: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 anonymous (state=08S01,code=0)

然后到网上查了一下资料,都是清一色的在hadoop的core-site.xml文件中加入以下配置(其中root需要替换成你使用beeline命令时-n指定的值):

<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>

<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>

 确实,改了core-site.xml文件配置以后重启hadoop集群,使用beeline进入hiveser2服务能成功,但是在里面对表数据进行更改时(eg: insert),同样还是报

Error: Could not open client transport with JDBC Uri: jdbc:hive2://hdp01: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 anonymous (state=08S01,code=0)

显然使用这种办法是不行的,后来我去官方文档查看hiveserver2配置时发现了关于impersonate (冒充)的配置选项。

解决办法

按照官方文档配置了以后,能够正常运行了,即使将上述配置移除以后,单独使用hive官方文档的配置也能正常使用。

 网址:https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2   

关键字: Impersonation

原文:

By default HiveServer2 performs the query processing as the user who submitted the query. But if the following parameter is set to false, the query will run as the user that the hiveserver2 process runs as.

hive.server2.enable.doAs – Impersonate the connected user, default true.

 这句话的意思是:默认情况下HiveServer2 执行查询时使用的用户是提交查询的用户.但是如果将这个选项设置为false,查询将会使用运行hiveserver2的用户。

在conf/hive-site.xml中加入以下配置:

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

然后使用命令bin/hiveserver2重新启动hiveserver2服务,然后使用beeline连接hiveser2,然后对表进行增删改查都不会报错了,同时使用beeline时都可以不用指定用户和密码了(bin/beeline -u jdbc:hive2://hdp01:10000)。

在此记录和共享出来。

原文地址:https://www.cnblogs.com/yangji0202/p/15012449.html