Created 07-24-2018 07:17 PM
am trying to connect hbase using JAVA HBase Rest Client. However it's giving following error.
The Hbase Rest uses kerberos authentication, and so I have created a kerberos ticket and trying to authenticate using this ticket.
code:
public class RestExample { public static void main(String[] args) throws IOException { Configuration conf = HBaseConfiguration.create(); UserGroupInformation.setConfiguration(conf); String projectDir = System.getProperty("user.dir"); System.out.println(projectDir); UserGroupInformation.loginUserFromKeytab("gaurang.shah@mydomain.com", projectDir+"/gaurang.shah.keytab"); // vv RestExample Cluster cluster = new Cluster(); cluster.add("hbase_host.mydomain.com", 17000); Client client = new Client(cluster); TableName tableName = TableName.valueOf("bda:aaa"); RemoteAdmin remoteAdmin = new RemoteAdmin(client, conf); HTableDescriptor tableDesc = new HTableDescriptor(tableName); remoteAdmin.createTable(tableDesc); } }
StackTrace:
Exception in thread "main" java.io.IOException: org.apache.hadoop.security.authentication.client.AuthenticationException: Authentication failed, URL: http://hbase_host.mydomain.com:17000/bda:aaa/schema?user.name=gaurang.shah, status: 403, message: Forbidden at org.apache.hadoop.hbase.rest.client.Client.negotiate(Client.java:285) at org.apache.hadoop.hbase.rest.client.Client.executeURI(Client.java:239) at org.apache.hadoop.hbase.rest.client.Client.executePathOnly(Client.java:204) at org.apache.hadoop.hbase.rest.client.Client.execute(Client.java:265) at org.apache.hadoop.hbase.rest.client.Client.put(Client.java:557) at org.apache.hadoop.hbase.rest.client.Client.put(Client.java:504) at org.apache.hadoop.hbase.rest.client.Client.put(Client.java:474) at org.apache.hadoop.hbase.rest.client.RemoteAdmin.createTable(RemoteAdmin.java:294) at ca.cantire.RestExample.main(RestExample.java:42) Caused by: org.apache.hadoop.security.authentication.client.AuthenticationException: Authentication failed, URL: http://hbase_host.mydomain.com:17000/bda:aaa/schema?user.name=gaurang.shah, status: 403, message: Forbidden at org.apache.hadoop.security.authentication.client.AuthenticatedURL.extractToken(AuthenticatedURL.java:281) at org.apache.hadoop.security.authentication.client.PseudoAuthenticator.authenticate(PseudoAuthenticator.java:77) at org.apache.hadoop.security.authentication.client.KerberosAuthenticator.authenticate(KerberosAuthenticator.java:212) at org.apache.hadoop.hbase.rest.client.Client.negotiate(Client.java:280) ... 8 more
Created 07-25-2018 10:15 PM
try this:
public static void main(String[] args) throws IOException { Configuration conf = HBaseConfiguration.create(); //Added this lines or you could also pass it using -djava.security.krb5.conf=/path/to/krb5.conf System.setProperty("java.security.krb5.conf", "/path/to/krb5.conf"); // Enable/disable krb5 debugging System.setProperty("sun.security.krb5.debug", "true"); String projectDir = System.getProperty("user.dir"); System.out.println(projectDir); String principal = System.getProperty("kerberosPrincipal", "gaurang.shah@mydomain.com"); String keytabLocation = System.getProperty("kerberosKeytab", projectDir+"/gaurang.shah.keytab"); UserGroupInformation.setConfiguration(conf); //UserGroupInformation.loginUserFromKeytab("gaurang.shah@mydomain.com", projectDir+"/gaurang.shah.keytab"); UserGroupInformation.loginUserFromKeytab(principal, keytabLocation); // vv RestExample Cluster cluster = new Cluster(); cluster.add("hbase_host.mydomain.com", 17000); Client client = new Client(cluster); TableName tableName = TableName.valueOf("bda:aaa"); RemoteAdmin remoteAdmin = new RemoteAdmin(client, conf); HTableDescriptor tableDesc = new HTableDescriptor(tableName); remoteAdmin.createTable(tableDesc); }
Created 07-27-2019 04:26 PM
Samir Caica, I tried your proposition but it doesn't help me, could you help me please? Thank you in advance.