spark读取hive phoenix映射

背景
最近在调研Kyuubi,由于原有作业中有使用Hive读取Phoenix映射表因此需要做一些适配.

过程
适配不需要改动代码,只需要拷贝相关jar到spark jars中即可(phoenix 以及hbase),拷贝完成后
直接通过spark-shell 测试可以正常读取Phoenix表,但是通过Kyuubi启动Spark Session后发现查询
一直报错。
报错信息(这里只贴出部分):
Caused by: org.apache.hadoop.hbase.exceptions.ConnectionClosingException:
根据报错信息查了很多文章都是与HiveServer2相关的,关闭HiveServer2用户模拟即可,另外通过对比
Kyuubi的Spark submit 发现其提供了 --proy-user 参数 ,这其实与上面的HiveServe2是类似的都是由于使用了
用户代理导致的,根据异常堆栈信息 发现报错是Hbase-client相关的代码导致的,因此这里下载的相关的代码
在其中加入了一些LOG 最终发下是如下代码导致的异常,对比Spark无 --proy-user参数的信息去除了如下注释的代码
部分后可以正常读取Phoenix表:
org.apache.hadoop.hbase.ipc.RpcConnection

private UserInformation getUserInfo(UserGroupInformation ugi) {
    if (ugi == null || authMethod == AuthMethod.DIGEST) {
      // Don't send user for token auth
      return null;
    }
    UserInformation.Builder userInfoPB = UserInformation.newBuilder();
    if (authMethod == AuthMethod.KERBEROS) {
      // Send effective user for Kerberos auth
      userInfoPB.setEffectiveUser(ugi.getUserName());
    } else if (authMethod == AuthMethod.SIMPLE) {
      // Send both effective user and real user for simple auth
      userInfoPB.setEffectiveUser(ugi.getUserName());
      ***// ***注释如下三行代码***
      //if (ugi.getRealUser() != null) {
      //  userInfoPB.setRealUser(ugi.getRealUser().getUserName());
      // }
    }***
    return userInfoPB.build();

}

你可能感兴趣的:(spark,hive,spark,hadoop)