Thanks Subroto dfs.namenode.kerberos.principal=hdfs/[email protected]<mailto:hdfs/[email protected]> this is principal specified here “UserGroupInformation.loginUserFromKeytab(String, String) “ or it is something different ?
From: Subroto Sanyal [mailto:[email protected]] Sent: 02 November 2015 19:54 To: [email protected] Subject: Re: Authenticating to Kerberos enabled Hadoop cluster using Java Hi Chhaya, Few configuration you need to set: hadoop.security.authentication=kerberos hadoop.security.authorization=true dfs.namenode.kerberos.principal=hdfs/[email protected]<mailto:hdfs/[email protected]> fs.defaultFS=hdfs://host:port Further you need to use org.apache.hadoop.security.UserGroupInformation.loginUserFromKeytab(String, String) as suggested in one of the trailing mail. Cheers, Subroto Sanyal On Mon, Nov 2, 2015 at 3:13 PM, Vishwakarma, Chhaya <[email protected]<mailto:[email protected]>> wrote: Code is successfully authenticating to Kerberos but when I try to run any hdfs command I get error as "Failed to specify server's kerberos principal name" Can somebody please assist me on this? Sent from my android device. -----Original Message----- From: andreina j <[email protected]<mailto:[email protected]>> To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Sent: Mon, 02 Nov 2015 4:57 pm Subject: RE: Authenticating to Kerberos enabled Hadoop cluster using Java Hi Chhaya, Please find below sample code . System.setProperty("java.security.krb5.conf", "D:\\data\\Desktop\\cluster-test\\krb5.conf"); // Login using keytab if have access to keytab. else UserGroupInformation.loginUserFromKeytab("hdfs/[email protected]<mailto:hdfs/[email protected]>", " D:\\data\\Desktop\\cluster-test\\conf\\hdfs.keytab"); Note: Above 2 lines should be at the beginning in your application. Regards Andreina J From: Vishwakarma, Chhaya [mailto:[email protected]<mailto:[email protected]>] Sent: 02 November 2015 PM 04:20 To: [email protected]<mailto:[email protected]> Subject: RE: Authenticating to Kerberos enabled Hadoop cluster using Java Thanks Niranjan It would be great if you can share a sample code if any? From: Niranjan Subramanian [mailto:[email protected]] Sent: 02 November 2015 16:18 To: [email protected]<mailto:[email protected]> Subject: Re: Authenticating to Kerberos enabled Hadoop cluster using Java Hi Chhaya, You can use the UserGroupInformation class from org.apache.hadoop.security package. Specifically following 2 methods of that class UserGroupInformation.setConfiguration(hdfsConfiguration); UserGroupInformation.loginUserFromKeytab(principal, keytabPath); Regards, Niranjan On 02-Nov-2015, at 4:15 pm, Vishwakarma, Chhaya <[email protected]<mailto:[email protected]>> wrote: I have Kerberos enabled Hadoop cluster, I need to perform HDFS operations using JAVA code. I have keytab file and username can someone please suggest how can I autheticate to Kerberos using JAVA code? Regards, Chhaya
