hive连接报错 Bad URL format. Hostname not found in authority part of the url “xxxxx” . Are you missing

报错 Bad URL format. Hostname not found  in authority part of the url “xxxxx” . Are you missing a '/' after the hostname ?

背景:用dbeaver连接kerberos认证的hive,之前都是好好的,今天手贱点了下重置结果按照以前的死活连不上报上面的错误,其实这个错以前也遇到过忘了怎么解决的。今天有时间就研究下。

 

 首先我们找到源码。怎么找源码?这个是连接hive报错的 大概率就是hiveConnection 和hiveDriver里解析hive url 和hive -d xxx=xxx这种时候出错了。详细过程不叙述了

org.apache.hive.jdbc.Utils类 526行左右

这里显示是host为null。 我这里贴出之前的hive 模板url

jdbc:hive2://{host}[:{port}][/{database}]/;AuthMech=1;KrbRealm=CDH.COM;KrbHostFQDN={host};KrbServiceName=hive;KrbAuthType=2

解析后的就是如下

jdbc:hive2://cdp-node05.data.com:10000;AuthMech=1;KrbRealm=CDH.COM;KrbHostFQDN=cdp-node05.data.com;KrbServiceName=hive;KrbAuthType=2

 明明显示了host为啥是null。 说实话吧这个源码有点难搞,最近刚好我还在学习如何debug hive源码,还没学会咋办????

注意上面的截图。

URI jdbcURI = URI.create(URI_HIVE_PREFIX + "//" + authority);

String host = jdbcURI.getHost();

其实也很简单我自己new一个uri然后gethost不就好了?

public class HiveUrlTest {
    public static void main(String[] args) {
        String auth="cdp-node05.data.com:10000;KrbHostFQDN=cdp-node05.data.com;KrbServiceName=hive;KrbAuthType=2"
        URI jdbcURI = URI.create("hive2:" + "//" +auth);
        System.out.println(jdbcURI.getHost());
    }
}

看了下uri的源码,说实话吧也能看,但很烦,不想看。

试了其他数据库的url,发现原因是少加了一个 /....

jdbc:hive2://{host}[:{port}][/{database}]/;principal=hive/{host}@CDP.COM;AuthMech=1;KrbRealm=CDH.COM;KrbHostFQDN={host};KrbServiceName=hive;KrbAuthType=2

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值