开发者社区> 问答> 正文

java连接hbase开启kerberos失败

叫我鹏爷 2018-11-17 23:20:57 1152

之前用java连接hbase是没有启动Kerberos认证,代码能连接到hbase,也能查询数据;现在启动kerberos认证后再次查询时却不能获取到数据
以下是我的代码,大牛们有知道哪儿出问题了(hbase是基于CDH5.13版本开发的)

                    System.setProperty("hadoop.home.dir", "/usr/hbase");
        conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.property.clientPort", zkPort); 
        conf.set("hbase.zookeeper.quorum", zkHost);
        conf.set("hbase.master", master);
        conf.set("hbase.master.kerberos.principal","hbase/_HOST@TEST.COM");        
        conf.set("hbase.regionserver.kerberos.principal","hbase/_HOST@TEST.COM");        
        conf.set("hbase.security.authentication","kerberos");
        conf.addResource("/usr/hbase/hbase-site.xml");
        String principal = System.getProperty("kerberosPrincipal", "hbase@TEST.COM");
        String keytabLocation = System.getProperty("kerberosKeytab",keyberos);
        UserGroupInformation.setConfiguration(conf);
        UserGroupInformation ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabLocation);
        ugi.reloginFromKeytab();
        conn = ConnectionFactory.createConnection(conf);

问题现象:开启认证后服务器能正常启动,也不报错。但是在查询中就出现以下错误信息:
DEBUG ResultBoundedCompletionService:226 - Replica 0 returns java.net.SocketTimeoutException: callTimeout=60000,

              callDuration=72022: Call to bdp02/10.127.60.2:60020 failed on local exception: javax.security.sasl.SaslException:    
              Failure to initialize security context [Caused by GSSException: Invalid name provided (Mechanism level: KrbException: 
              Cannot locate default realm)] row 'hbase_person_ecif,6610fc0ad0d6745f39310624bfe761ad,99999999999999' on 
             table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=bdp02,60020,1542464877235, seqNum=0

DEBUG ConnectionImplementation:911 - locateRegionInMeta parentTable=hbase:meta, metaLocation=, attempt=0 of 36 failed;

             retrying after sleep of 100 because: Failed after attempts=36, exceptions:
             Sat Nov 17 22:53:32 CST 2018, null, java.net.SocketTimeoutException: callTimeout=60000, callDuration=72022: Call to 
             bdp02/10.127.60.2:60020 failed on local exception: javax.security.sasl.SaslException: Failure to initialize security 
             context [Caused by GSSException: Invalid name provided (Mechanism level: KrbException: Cannot locate default 
             realm)] row 'hbase_person_ecif,6610fc0ad0d6745f39310624bfe761ad,99999999999999' on table 'hbase:meta' at 
             region=hbase:meta,,1.1588230740, hostname=bdp02,60020,1542464877235, seqNum=0
安全 Java 分布式数据库 Hbase
分享到
取消 提交回答
全部回答(0)
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题