2016-05-09 94 views
0

我啓用了Kerberos以保護hadoop和生成主鍵[email protected]的密鑰選項卡,並在我執行時使用hbase shell -grant命令提供測試用戶RX(讀取執行)權限 kinit - -t test.keytab [email protected]當啓用Kerberos時無法連接到Hbase

一切正常。我正在試圖做同樣的事情就像通過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("[email protected]", "D:\\mohanv.keytab"); 
     //UserGroupInformation userGroupInformation = UserGroupInformation.loginUserFromKeytabAndReturnUGI("[email protected]", "/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 
+0

啓用調試日誌後我得到警告 2016-05-10 11:29:18警告AbstractRpcClient:695 - 無法將[email protected]連接設置爲null –

+0

更多調試選項:https:// github.com/steveloughran/kerberos_and_hadoop/blob/master/sections/secrets.md –

回答

0

我相信你還需要建立服務主體在HBase的配置。以下屬性必須存在,與被配置爲您的HBase的主站和區域服務器的服務主體:

hbase.master.kerberos.principal hbase.regionserver.kerberos.principal

另一種方法是HBase的-site.xml中添加到類路徑,這應具有這些性能設置。