WARN jdbc.HiveConnection: Failed to connect to localhost:10000 Error: Could not open client trans...

在启动hiveserver2后,使用beeline远程连接:

beeline -u jdbc:hive2://localhost:10000

无法连接成功,并报如下错:
WARN jdbc.HiveConnection: Failed to connect to localhost:10000
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost: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)
为用户权限问题。

解决办法:

找到core-site.xml,..../hadoop安装目录/etc/hadoop/core-site.xml
添加/修改(其中XXX为用户名,如:root、zhangsan等):

<property>
                  <name>hadoop.proxyuser.XXX.hosts</name>
                  <value>*</value>
</property>
<property>
                 <name>hadoop.proxyuser.XXX.groups</name>
                 <value>*</value>
</property>

然后stop-dfs.sh、stop-yarn.sh、start-dfs.sh、start-yarn.sh(重启hadoop),否则以上修改不生效。
再次执行:

beeline -u jdbc:hive2://localhost:10000

即可连接成功。

推荐阅读更多精彩内容