13、【Hive】hive在启动beeline客户端时报错:User: xxx is not allowed to impersonate xxx

  • 背景

    在启动完成hive服务:hive --service metastore

    启动hive2服务的过程中:hive --service hiveserver2

    启动beeline客户端时,beeline -u jdbc:hive2://pc001:10000 -n nuochengze

    报错:

    java.lang.RuntimeException: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: nuochengze is not allowed to impersonate nuochengze

  • 分析

    通过hive的thrift服务来实现跨语言访问Hive数据仓库,但是hadoop引入了一个安全伪装机制,使得hadoop不允许上层系统直接将实际用户传递到hadoop层,而是将实际用户传递给一个超级代理,由此代理在hadoop上执行操作,从而避免任意客户端随意操作hadoop。

  • 解决措施

    在hive-site.xml中添加

    <!-- yarn作业获取到的hiveserver2用户都为hive用户,设置成true则为实际的用户名-->
    <property>
     <name>hive.server2.enable.doAs</name>
     <value>true</value>
    </property>     
    

    之后在hadoop的core-site.xml中添加

    <property>
      <name>hadoop.proxyuser.yourusename.groups</name>
    <value>*</value>
    </property>
    
    <property>
     <name>hadoop.proxyuser.yourusename.hosts</name>
     <value>*</value>
    </property>
    
  • 效果

原文地址:https://www.cnblogs.com/nuochengze/p/15343407.html