hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Elser <josh.el...@gmail.com>
Subject Re: Kerberos auth using java exception
Date Tue, 22 Mar 2016 03:54:05 GMT
`UserGroupInformation ugi = 
UserGroupInformation.loginUserFromKeytabAndReturnUGI(...)`

and

`UserGroupInformation.setLoginUser(ugi)`

Should be sufficient. You may also need to use a `UGI.doAs()`, e.g.

ugi.doAs(new PrivilegedExceptionAction<Void>() {
   public Void run() {
     HBaseAdmin.checkHBaseAvailable(hBaseConfig);
     Connection connection = 
ConnectionFactory.createConnection(hBaseConfig);
   }
});

Also, try setting -Dsun.security.krb5.debug=true when launching your 
application to get more information as to what is happening. As Ted 
pointed out, it doesn't appear that your Kerberos login occurred.

Saurabh Malviya (samalviy) wrote:
> Hi,
>
> I am trying to write java code snippet to authenticate hbase using
> Kerberos, But I am getting attached exception. I tried all kind of
> config through code but no luck.
>
> -Saurabh
>
> ---Java Code
>
> HbaseGetPropertyValues properties = new HbaseGetPropertyValues();
>
> properties.getPropValues();
>
> Configuration hBaseConfig = HBaseConfiguration.create();
>
> hBaseConfig.setInt("timeout", Integer.parseInt(properties.TIMEOUT));
>
> hBaseConfig.set("hbase.zookeeper.quorum",
> properties.HBASE_ZOOKEEPER_QUORUM);
>
> //hBaseConfig.set("hbase.master", "hdfs-hbase-m1.insight-test-1:60000");
>
> hBaseConfig.set("hbase.zookeeper.property.clientport",
> properties.HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT);
>
> hBaseConfig.set("zookeeper.znode.parent",
> properties.ZOOKEEPER_ZNODE_PARENT);
>
> //hBaseConfig.set("hadoop.security.authentication", "kerberos");
>
> hBaseConfig.set("hbase.security.authentication", "kerberos");
>
> hBaseConfig.set("hbase.master.kerberos.principal", "test/INSIGHT@INSIGHT");
>
> hBaseConfig.set("hbase.regionserver.kerberos.principal",
> "test/INSIGHT@INSIGHT");
>
> hBaseConfig.set("hbase.master.keytab.file", "/root/test.keytab");
>
> hBaseConfig.set("hbase.regionserver.keytab.file", "/root/test.keytab");
>
> //runLoginAndRenewalThread(hBaseConfig, "/root/test.keytab",
> "test/INSIGHT@INSIGHT");
>
> UserGroupInformation.setConfiguration(hBaseConfig);
>
> User.login(hBaseConfig,"hbase.master.keytab.file",
> "hbase.regionserver.kerberos.principal", null);
>
> //UserGroupInformation.loginUserFromKeytab("test/INSIGHT@INSIGHT","/root/test.keytab");
>
> UserGroupInformation ugi =
> UserGroupInformation.loginUserFromKeytabAndReturnUGI("test/INSIGHT@INSIGHT","/root/samalviy.keytab");
>
> UserGroupInformation.setLoginUser(ugi);
>
> System.out.println("getLoginUser :: "+ugi.getLoginUser());
>
> System.out.println(hBaseConfig);
>
> HBaseAdmin.checkHBaseAvailable(hBaseConfig);
>
> Connection connection = ConnectionFactory.createConnection(hBaseConfig);
>

Mime
View raw message