解决:hive用hiveserver2连接jdbc出现问题 Error: Could not open client transport with JDBC Uri:jdbc:hive2://

解决:hive用hiveserver2连接jdbc出现问题 Error: Could not open client transport with JDBC Uri:jdbc:hive2://hadoop1:10000

在用jdbc连接hive的时候,出现下面的错误

Error: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop1:10000: 
Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): 
User: andy is not allowed to impersonate andy (state=08S01,code=0)

image-20211124213810314

解决办法:

1、在hadoop中core-site.xml中添加:



  hadoop.proxyuser.用户名.hosts
  *


  hadoop.proxyuser.用户名.groups
  *

image-20211125091021278注意:用户名要修改成自己的

2、重新启动hadoop集群

3、在用jdbc连接hive

注意:

  • 先将metastore开启

    $HIVE_HOME/bin/hive --service metastore
    
  • 再开启hiveserver2

    $HIVE_HOME/bin/hive --service hiveserver2
    

    image-20211125092247021

  • 需要等hiveserver2执行完成后,才能再执行jdbc连接hive,不是报错拒绝连接
    image-20211125102835646

$HIVE_HOME/bin/beeline -u jdbc:hive2://hadoop1:10000 -n andy(用户名)

image-20211125093937668

你可能感兴趣的:(大数据,jar,linux,hadoop,hive)