hadoop - 启用 Kerberos 时无法连接到 Hbase

标签 hadoop hbase kerberos

我启用了 Kerberos 来保护 hadoop 并为主体 test@EXAMPLE.COM 生成 key 选项卡,并在我这样做时使用 hbase shell -grant 命令提供了测试用户 RX(读取执行)权限
kinit -k -t test.keytab test@EXAMPLE.COM

一切正常。我正在尝试使用以下代码通过 Java 代码/Java 客户端读取表格

     System.setProperty("java.security.krb5.realm", "EXAMPLE.COM");
        System.setProperty("java.security.krb5.kdc", "D-9539.mydomain.com");
        //System.setProperty("sun.security.krb5.debug", "true");

    Configuration config = HBaseConfiguration.create();
    config.set("hadoop.security.authentication", "Kerberos");
    config.set("hbase.security.authentication", "kerberos");
    UserGroupInformation.setConfiguration(config);
    config.set("hbase.zookeeper.quorum", "D-9539.mydomain.com");
    config.setInt("zookeeper.recovery.retry",1);
    config.set("zookeeper.znode.parent","/hbase-secure");
    config.set("hbase.client.retries.number", Integer.toString(2));
    config.set("zookeeper.session.timeout", Integer.toString(60000));
      UserGroupInformation userGroupInformation = UserGroupInformation.loginUserFromKeytabAndReturnUGI("mohanv@EXAMPLE.COM", "D:\\mohanv.keytab" );
      //UserGroupInformation userGroupInformation = UserGroupInformation.loginUserFromKeytabAndReturnUGI("hbase-D9539@EXAMPLE.COM", "/Users/guest/Work/workspace/hbase.headless.keytab" );
    UserGroupInformation.setLoginUser(userGroupInformation);
    Connection conn = ConnectionFactory.createConnection(config);
    TableName tablename=TableName.valueOf("tweetTest2");
    Table table = conn.getTable(tablename);
    Get get=new Get(Bytes.toBytes("row1")) ;
    get.addFamily(Bytes.toBytes("twt"));

    System.out.println(Bytes.toString(table.get(get).getRow()));

但是得到
org.apache.hadoop.hbase.client.RetriesExhaustedException:

进而
clientClosingConnectionException

最佳答案

我相信您还需要在 HBase 配置中设置服务主体。必须存在以下属性,并配置 HBase 主服务器和区域服务器的服务主体:
hbase.master.kerberos.principal hbase.regionserver.kerberos.principal
另一种选择是将 hbase-site.xml 添加到类路径中,它应该设置这些属性。

关于hadoop - 启用 Kerberos 时无法连接到 Hbase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37124148/

相关文章:

hadoop - HBase 区域服务器 : error telling master we are up

scala - 使用结构化 Spark Streaming 在 HBase 中批量插入数据

hadoop - 如何增加hadoop计数器编号

hadoop - Nutch之hBase数据存储(网页)的理解

hadoop - hadoop LocalJobRunner无法正常工作?

sql-server - SSPI 提供程序 : Server not found in Kerberos database

java - "renew until"的 Kerberos 自动更新

hadoop - 在配置单元中生成唯一 ID

hadoop - HBase 过滤器比较两列

apache-spark - Kafka kerberos 配置问题